<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class UpdateProjectRequest extends FormRequest
{
    public function authorize(): bool
    {
        // only allow admins
        return auth()->check() && auth()->user()->role === 'admin';
    }

    public function rules(): array
    {
        return [
            'name' => 'required|string|max:255',
            'description' => 'nullable|string',
            'status' => 'required|in:requirement change,voting,calculate,done',
        ];
    }

    public function messages(): array
    {
        return [
            'name.required' => 'The project name is required.',
            'status.required' => 'The status is required.',
            'status.in' => 'Invalid status selected.',
        ];
    }
}
