*/ protected $fillable = [ 'name', 'phone', 'email', 'status', 'password', 'role_id', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; protected function status(): Attribute { return Attribute::make( get:fn($value) => $value ? __('words.active') : __('words.not_active'), ); } public function role() { return $this->belongsTo(Role::class); } public function scopeFilter($query, array $filters) { $query->when($filters['search'] ?? null, function ($query, $search) { $query->where(function ($query) use ($search) { $query->where('name', 'like', '%' . $search . '%') ->orWhere('phone', 'like', '%' . $search . '%') ->orWhere('email', 'like', '%' . $search . '%'); }); }); } }