<?php
namespace App\Http\Requests\Candidat;

use Illuminate\Foundation\Http\FormRequest;

class UpdateProfilCandidatRequest extends FormRequest
{
    public function authorize(): bool
    {
        return auth()->check() && auth()->user()->isCandidat();
    }

    public function rules(): array
    {
        return [
            'nom'                  => ['sometimes', 'string', 'max:100'],
            'prenom'               => ['sometimes', 'string', 'max:100'],
            'date_naissance'       => ['sometimes', 'date', 'before:today', 'after:1950-01-01'],
            'sexe'                 => ['sometimes', 'in:femme,homme'],
            'nationalite'          => ['sometimes', 'string', 'max:100'],
            'telephone'            => ['sometimes', 'string', 'max:30'],
            'type_situation'       => ['sometimes', 'in:residente,non_residente'],
            'disponibilite'        => ['sometimes', 'array'],
            'disponibilite.*'      => ['string', 'in:lundi,mardi,mercredi,jeudi,vendredi,samedi,dimanche'],
            'description'          => ['sometimes', 'nullable', 'string', 'max:1000'],
            'quartier_domicile_id' => ['sometimes', 'nullable', 'exists:quartiers,id'],
            'ville_id'             => ['sometimes', 'exists:villes,id'],
            'adresse_domicile'     => ['sometimes', 'nullable', 'string', 'max:500'],
        ];
    }
}
