<?php

namespace App\Models;

use App\Enums\NutritionPlanStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class NutritionPlan extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = ['athlete_id', 'coach_id', 'name', 'description', 'status'];

    protected function casts(): array
    {
        return ['status' => NutritionPlanStatus::class];
    }

    public function athlete()
    {
        return $this->belongsTo(Athlete::class);
    }

    public function coach()
    {
        return $this->belongsTo(Coach::class);
    }

    public function days()
    {
        return $this->hasMany(NutritionDay::class)->orderBy('sort_order');
    }

    public function forbiddenFoods()
    {
        return $this->hasMany(ForbiddenFood::class);
    }

    public function supplements()
    {
        return $this->hasMany(Supplement::class);
    }
}
