AccountType::class ]; /** * Account * * @param array $attributes */ public function __construct(array $attributes = []) { self::$editableProperties = [ 'label' => [ 'label' => trans('Label'), 'placeholder' => trans('Nom du compte'), 'type' => CrudType::string(), 'validate' => [ 'string', 'max:255' ], 'required' => true, 'nullable' => false, 'actions' => [ CrudAction::viewAny(), CrudAction::view(), CrudAction::create(), CrudAction::update(), ] ], 'type' => [ 'label' => trans('Type'), 'type' => CrudType::enum(), 'enum' => AccountType::class, 'required' => true, 'nullable' => false, 'actions' => [ CrudAction::viewAny(), CrudAction::view(), CrudAction::create(), CrudAction::update(), ] ], 'balance' => [ 'label' => trans('Solde'), 'type' => CrudType::float(), 'required' => false, 'nullable' => false, 'readonly' => true, 'step' => 0.5, 'validate' => [ 'numeric', function ($attribute, $value, $fail) { if (($value * 10) % 5 !== 0) { $fail("$attribute doit ĂȘtre divisible par 0.5 jour/homme"); } }, ], 'actions' => [ CrudAction::viewAny(), CrudAction::view(), CrudAction::create(), CrudAction::update(), ] ], 'brand' => [ 'label' => Str::singular(trans('models.classes.brands')), 'type' => CrudType::belongsTo(), 'belongsTo' => Brand::class, 'required' => false, 'nullable' => false, 'actions' => [ CrudAction::viewAny() ] ] ]; parent::__construct($attributes); } // * RELATIONSHIPS /** * BelongsTo Brand relation * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function brand() { return $this->belongsTo(Brand::class); } }