100 lines
2.2 KiB
PHP
100 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin;
|
|
use App\Enums\FlightStatus;
|
|
use App\Enums\FlightType;
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class FlightStoreRequest 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 [
|
|
'arrival_aiport_id' => [
|
|
'required',
|
|
'integer',
|
|
'exists:airports,id',
|
|
],
|
|
|
|
'departure_airport_id' => [
|
|
'required',
|
|
'integer',
|
|
'exists:airports,id',
|
|
'different:arrival_aiport_id',
|
|
],
|
|
|
|
'airline_id' => [
|
|
'required',
|
|
'integer',
|
|
'exists:airlines,id',
|
|
],
|
|
|
|
|
|
'title' => [
|
|
'required',
|
|
'string',
|
|
'max:255',
|
|
],
|
|
|
|
'summary' => [
|
|
'nullable',
|
|
'string',
|
|
],
|
|
|
|
'flight_type' => [
|
|
'required',
|
|
'integer',
|
|
Rule::in([
|
|
FlightType::DEPARTURE->value,
|
|
FlightType::RETURN->value,
|
|
FlightType::ROUNDTRIP->value,
|
|
]),
|
|
],
|
|
|
|
'departure_time' => [
|
|
'required',
|
|
'date',
|
|
],
|
|
|
|
'price' => [
|
|
'required',
|
|
'numeric',
|
|
'min:0',
|
|
],
|
|
|
|
|
|
'image' => [
|
|
'required',
|
|
'image',
|
|
'mimes:jpg,jpeg,png,webp',
|
|
'max:2048',
|
|
],
|
|
|
|
'status' => [
|
|
'required',
|
|
'integer',
|
|
Rule::in([
|
|
FlightStatus::DISABLE->value,
|
|
FlightStatus::ENABLE->value,
|
|
]),
|
|
],
|
|
];
|
|
}
|
|
}
|