improve code in controller and form request for V3 whit pint package
This commit is contained in:
@@ -39,27 +39,28 @@ class ContinueMissionRequest extends FormRequest
|
||||
'area' => 'required|array',
|
||||
'area.type' => 'required|string',
|
||||
'area.coordinates' => 'required|array',
|
||||
'explanation' => 'required|string',
|
||||
'explanation' => 'required|string',
|
||||
'category_id' => 'required|in:1,2,3',
|
||||
'road_observed_id' => 'required_if:category_id,3|exists:road_observeds,id',
|
||||
];
|
||||
}
|
||||
|
||||
public function after(): array
|
||||
{
|
||||
return [
|
||||
function (Validator $validator) {
|
||||
if ($this->type == 1){
|
||||
if ($this->type == 1) {
|
||||
$start = Carbon::parse($this->start_date);
|
||||
$end = Carbon::parse($this->end_date);
|
||||
|
||||
if ($start->diffInMinutes($end) > 480){
|
||||
if ($start->diffInMinutes($end) > 480) {
|
||||
$validator->errors()->add(
|
||||
'end_date',
|
||||
'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user