<?php

namespace App\Http\Requests;

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

class ParticipationRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'forum_id' => [
                'required',
                'integer',
                //Rule::unique('participations')->where([[]])
            ],
            'commune_id' => [
                'required',
                'integer'
            ],
            'pf_name' => [
                'string',
                'required',
            ],
            'pf_poste' => [
                'string',
                'nullable',
            ],
            'pf_phone' => [
                'string',
                'nullable',
            ],
            'pf_email' => [
                'email',
                'nullable',
            ],
            'rapports' => [
                'string',
                'nullable'
            ],
            'messages' => [
                'string',
                'nullable'
            ],
            'engagements' => [
                'string',
                'nullable'
            ]
        ];

        return $rules;
    }

    public function getParticipationPayload()
    {
        return collect($this->validated())
            ->toArray();
    }
}
