$dishes * @property Collection $userDishes * @method static User findOrFail(int $user_id) * @method static UserFactory factory($count = null, $state = []) */ class User extends Authenticatable { /** @use HasFactory */ use HasFactory, Notifiable; protected $fillable = [ 'planner_id', 'name', 'email', 'password', ]; protected $hidden = [ 'password', 'remember_token', ]; protected static function booted(): void { static::addGlobalScope(new BelongsToPlanner); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', ]; } public function dishes(): BelongsToMany { return $this->belongsToMany(Dish::class, 'user_dishes', 'user_id', 'dish_id'); } public function userDishes(): HasMany { return $this->hasMany(UserDish::class); } public function recurrences(): HasManyThrough { return $this->hasManyThrough( UserDishRecurrence::class, UserDish::class, 'user_id', // Foreign key on user_dishes 'user_dish_id', // Foreign key on user_dish_recurrences 'id', // Local key on users 'id' // Local key on user_dishes ); } }