[ 'label' => Str::ucfirst(trans('models.common.email')), 'type' => CrudType::email(), 'validate' => [ 'required', 'email:rfc,dns', // @phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed function ($attribute, $value, $fail) { $q = static::query(); if (request()->user) { $q = $q->where('id', '!=', $this->id); } if ($q->where('email', $value)->exists()) { $fail(__(':attribute est déjà utilisé', [ 'attribute' => $attribute ])); } } ], 'actions' => [ CrudAction::viewAny(), CrudAction::view(), CrudAction::create(), CrudAction::update() ] ], 'brand_id' => [ 'label' => Str::ucfirst(trans('models.classes.brand')), 'type' => CrudType::belongsTo(), 'belongsTo' => Brand::class, 'actions' => [ CrudAction::viewAny(), CrudAction::view() ] ], 'created_at' => [ 'label' => Str::ucfirst(trans('models.common.optinDate')), 'type' => CrudType::string(), 'readonly' => true, 'actions' => [ CrudAction::viewAny(), CrudAction::view(), CrudAction::update() ] ], ]; parent::__construct($attributes); } // * RELATIONS /** * Brand BelongsTo relation * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function brand() { return $this->belongsTo(Brand::class); } }