*/ use HasFactory; use Notifiable; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', 'city', 'mobile_number', 'role', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; public function hasFavorited(Product $product): bool { return $this->favoriteProducts()->where('product_id', $product->id)->exists(); } public function favoriteProducts(): BelongsToMany { return $this->belongsToMany(Product::class, 'favorite_products', 'user_id', 'product_id'); } /** * @return HasMany */ public function carts(): HasMany { return $this->hasMany(Cart::class); } /** * @return BelongsToMany
*/ public function addresses(): BelongsToMany { return $this->belongsToMany(Address::class); } /** * @return HasMany */ public function orders(): HasMany { return $this->hasMany(Order::class); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'role' => UserRoles::class, ]; } }