|string> */ public function rules(): array { return [ 'airline' => [ 'required', 'string', 'max:100' ], 'flight_number' => [ 'required', 'string', 'max:50' ], 'origin' => [ 'required', 'string', 'max:100' ], 'destination' => [ 'required', 'string', 'max:100' ], 'departure_date' => [ 'required', function ($attribute, $value, $fail) { try { $gregorian = Verta::parse($value) ->formatGregorian('Y-m-d'); } catch (\Exception $e) { $fail('تاریخ حرکت معتبر نیست.'); return; } if ($gregorian < now()->format('Y-m-d')) { $fail('تاریخ حرکت نمی‌تواند قبل از تاریخ امروز باشد.'); } }, ], 'departure_time' => [ 'required', 'date_format:H:i' ], 'arrival_time' => [ 'required' ], 'flight_class' => [ 'nullable', 'string', 'max:50' ], 'capacity' => [ 'required', 'integer', 'min:1' ], 'price' => [ 'required', 'numeric', 'min:0' ], 'image' => [ $this->isMethod('put') || $this->isMethod('patch') ? 'nullable' : 'required', 'image', 'mimes:jpg,jpeg,png,webp', 'max:2048' ], 'views'=>[ 'nullable', 'integer', 'min:0' ], 'type' => [ 'required', 'integer', 'in:0,2,3' ], 'status' => [ 'required', 'in:0,1,2,3,4' ] ]; } }