<?php

namespace App\Http\Requests\Coach;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class NutritionItemRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->isCoach();
    }

    public function rules(): array
    {
        return [
            'food_name' => ['required', 'string', 'max:150'],
            'amount' => ['nullable', 'numeric', 'min:0'],
            'unit' => ['required', Rule::in(['gram', 'kg', 'ml', 'liter', 'cup', 'tablespoon', 'teaspoon', 'piece', 'slice', 'other'])],
            'calories' => ['nullable', 'integer', 'min:0', 'max:10000'],
            'notes' => ['nullable', 'string', 'max:300'],
        ];
    }
}
