improve code in controller and form request for V3 whit pint package
This commit is contained in:
@@ -33,13 +33,13 @@ class StartRequest extends FormRequest
|
||||
{
|
||||
return [
|
||||
function (Validator $validator) {
|
||||
if ($this->mission->code != $this->code){
|
||||
if ($this->mission->code != $this->code) {
|
||||
$validator->errors()->add(
|
||||
'code',
|
||||
'کد وارد شده صحیح نمی باشد'
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class NoProcessRequest extends FormRequest
|
||||
'area.type' => 'required|string',
|
||||
'area.coordinates' => 'required|array',
|
||||
'category_id' => 'required|in:1,2,3',
|
||||
'explanation' => 'required|string',
|
||||
'explanation' => 'required|string',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class StoreRequest 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',
|
||||
];
|
||||
@@ -47,18 +47,18 @@ class StoreRequest extends FormRequest
|
||||
{
|
||||
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',
|
||||
'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.'
|
||||
'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class UpdateRequest 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',
|
||||
];
|
||||
@@ -48,18 +48,18 @@ class UpdateRequest extends FormRequest
|
||||
{
|
||||
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',
|
||||
'مدت زمان مأموریت ساعتی نباید بیشتر از ۸ ساعت باشد.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\V3\Mission\TransportaionUnit;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class AllocateRequest extends FormRequest
|
||||
@@ -18,7 +19,7 @@ class AllocateRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Requests\V3\Mission\TransportaionUnit;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class DeallocateRequest extends FormRequest
|
||||
@@ -18,7 +19,7 @@ class DeallocateRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user