feat: add flight request validation
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class FlightUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'travel_type_id' =>
|
||||
[
|
||||
'required',
|
||||
'exists:travel_types,id'
|
||||
],
|
||||
'flight_number' =>
|
||||
[
|
||||
'required',
|
||||
'string',
|
||||
'max:50'
|
||||
],
|
||||
'airline_name' =>
|
||||
[
|
||||
'required',
|
||||
'string',
|
||||
'max:150'
|
||||
],
|
||||
'origin' =>
|
||||
[
|
||||
'required',
|
||||
'string',
|
||||
'max:150'
|
||||
],
|
||||
'destination' =>
|
||||
[
|
||||
'required',
|
||||
'string',
|
||||
'max:100'
|
||||
],
|
||||
'departure_date' =>
|
||||
[
|
||||
'required',
|
||||
'date'
|
||||
],
|
||||
'departure_time' =>
|
||||
[
|
||||
'required',
|
||||
'date_format:H:i'
|
||||
],
|
||||
'arrival_date' =>
|
||||
[
|
||||
'required',
|
||||
'date',
|
||||
'after_or_equal:departure_date'
|
||||
],
|
||||
'arrival_time' =>
|
||||
[
|
||||
'required',
|
||||
'date_format:H:i'
|
||||
],
|
||||
'duration' =>
|
||||
[
|
||||
'required',
|
||||
'string',
|
||||
'max:50'
|
||||
],
|
||||
'price' =>
|
||||
[
|
||||
'required',
|
||||
'numeric',
|
||||
'min:0'
|
||||
],
|
||||
'capacity' =>
|
||||
[
|
||||
'required',
|
||||
'integer',
|
||||
'min:1'
|
||||
],
|
||||
'status' =>
|
||||
[
|
||||
'required',
|
||||
'in:0,1'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user