<?php

namespace App\Http\Requests\V3\Mission\RequestPortal;

use App\Enums\MissionStates;
use Illuminate\Foundation\Http\FormRequest;

class UpdateRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return $this->mission->user_id === auth()->user()->id && $this->mission->state_id == MissionStates::REJECT_BY_TRANSPORTATION->value;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'rahdaran' => 'required|array',
            'rahdaran.*' => 'exists:rahdaran,id',
            'requested_machines' => 'required|array',
            'type' => 'required|in:1,2',
            'zone' => 'required|in:1,2,3',
            'start_date' => 'required|date',
            'end_date' => 'required|date',
            'description' => 'string',
            'end_point' => 'required|string',
            'area' => 'required|array',
        ];
    }
}
