*/ use HasFactory, Notifiable; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ 'name', 'email', 'password', 'age', 'weight_kg', 'height_cm', 'fitness_level', 'goal', 'health_notes', 'available_equipment', 'days_per_week', 'minutes_per_session', ]; /** * The attributes that should be hidden for serialization. * * @var list */ protected $hidden = [ 'password', 'remember_token', ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'age' => 'integer', 'weight_kg' => 'decimal:2', 'height_cm' => 'decimal:2', 'days_per_week' => 'integer', 'minutes_per_session' => 'integer', ]; } // Relationships public function workouts() { return $this->hasMany(Workout::class); } public function favoriteExercises() { return $this->belongsToMany(Exercise::class, 'exercise_favorites')->withTimestamps(); } public function favoriteWorkouts() { return $this->belongsToMany(Workout::class, 'workout_favorites')->withTimestamps(); } // Helpers public function hasFavoritedExercise(Exercise $exercise): bool { return $this->favoriteExercises()->where('exercise_id', $exercise->id)->exists(); } public function hasFavoritedWorkout(Workout $workout): bool { return $this->favoriteWorkouts()->where('workout_id', $workout->id)->exists(); } }