*/ protected $fillable = [ 'username', 'email', 'password', 'phone_number', 'role', 'email_verified_at', 'login_otp', 'login_otp_expires_at', ]; /** * 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', 'login_otp_expires_at' => 'datetime', 'password' => 'hashed', ]; /** * Get the user's favorite cars */ public function favorites() { return $this->hasMany(Favorite::class, 'username', 'username'); } /** * Get the categories that the user has favorited */ public function favoriteCategories() { return $this->belongsToMany(Category::class, 'favorites', 'username', 'category_id', 'username', 'id'); } }