Files
shahrzadzandi09/app/Http/Requests/AirportStoreRequest.php

73 lines
1.7 KiB
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
class AirportStoreRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
protected function prepareForValidation(): void
{
// کد فرودگاه همیشه با حروف بزرگ ذخیره شود (IATA)
if ($this->has('code')) {
$this->merge([
'code' => strtoupper($this->input('code')),
]);
}
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'name' =>
[
'required',
'string',
'max:150'
],
'city' =>
[
'required',
'string',
'max:100'
],
'province' =>
[
'required',
'string',
'max:100'
],
'code' =>
[
'required',
'string',
'max:10'
],
];
}
public function attributes(): array
{
return [
'name' => 'نام فرودگاه',
'city' => 'شهر',
'country' => 'کشور',
'code' => 'کد فرودگاه',
];
}
}