<?php

namespace App\Http\Requests\Gatepass;

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

class UpdateGatepassRequest extends FormRequest
{
	public function authorize(): bool { return true; }
	public function rules(): array
	{
		$cur=$this->route('gatepass');
		$id=$cur?$cur->id:null;
		return [
			'gate_pass_number'=>['required','string','max:255', Rule::unique('gate_passes','gate_pass_number')->ignore($id)],
			'contact_id'=>['required','integer','exists:contacts,id'],
			'date'=>['required','date'],
			'type'=>['required','in:inbound,outbound'],
			'vehicle_no'=>['required','string','max:255'],
			'driver_name'=>['nullable','string','max:255'],
			'other_persons'=>['nullable','string'],
			'remarks'=>['nullable','string']
		];
	}
}
