git add .
git commit "Complete project development and finalize features"
This commit is contained in:
@@ -16,6 +16,27 @@ class FlightStoreRequest extends FormRequest
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
if ($this->departure_date) {
|
||||
|
||||
try {
|
||||
|
||||
$this->merge([
|
||||
'departure_date' => verta($this->departure_date)
|
||||
->formatGregorian('Y-m-d')
|
||||
]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
|
||||
$this->merge([
|
||||
'departure_date' => null
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -46,20 +67,7 @@ class FlightStoreRequest extends FormRequest
|
||||
],
|
||||
'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('تاریخ حرکت نمیتواند قبل از تاریخ امروز باشد.');
|
||||
}
|
||||
},
|
||||
'date'
|
||||
],
|
||||
'departure_time' => [
|
||||
'required',
|
||||
|
||||
Reference in New Issue
Block a user