<?php

namespace Functional\Tracking\Http\Requests;

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

/**
 * Validation du démarrage d'une séance (POST /api/sessions).
 */
class StoreWorkoutSessionRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'routine_id' => [
                'nullable',
                'integer',
                Rule::exists('routines', 'id')->where(fn ($query) => $query->where('user_id', $this->user()?->id)),
            ],
            'title' => ['nullable', 'string', 'max:255'],
        ];
    }
}
