namespace App\Nova;
+use Carbon\Carbon;
+use Laravel\Nova\Fields\DateTime;
+use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
class DiscoverUsers extends User
}
+ protected function extraFields()
+ {
+ return [
+ Text::make('Fin essai', function() {
+ /** @var Carbon $date */
+ $date = $this->trial_ends_at ?? $this->discover_ends_at;
+ return $date === null ?
+ null :
+ $date->format('d/m/Y');
+ })
+ ];
+ }
+
}
*/
public function fields(Request $request)
{
- return [
+ return array_merge([
// ID::make()->sortable(),
Text::make('Prénom', 'first_name'),
Text::make('Nom', 'last_name'),
new Panel('Affiliation', [
BelongsTo::make('Organisation', 'organization', Organization::class)->searchable()->nullable(),
]),
+ ], $this->extraFields(), [
Boolean::make('Compte activé', 'reg_complete')->hideWhenCreating(),
Select::make('Type')->options([
AppUser::TYPE_SUBSCRIBER => 'Abonné',
])->hideFromIndex()->required()->withMeta(['value' => $this->type ?? static::$type ?? AppUser::TYPE_SUBSCRIBER]),
Badge::make('Etat', fn() => AppUser::STATUSES[$this->status]['label'])
->map(Arr::pluck(AppUser::STATUSES, 'badge', 'label')),
- ];
+ ]);
}
+ /**
+ * @return array
+ */
+ protected function extraFields()
+ {
+ return [];
+ }
/**
* Get the address fields for the resource.