creat new column for CmmsMachines and improve notification for mission and valdation for formrequest
This commit is contained in:
@@ -197,18 +197,67 @@ class NotificationController extends Controller
|
||||
'control' => 0,
|
||||
];
|
||||
|
||||
if ($user->hasPermissionTo('manage-transportation-unit')) {
|
||||
if ($user->hasPermissionTo('manage-transportation-unit-station')) {
|
||||
$missions['transportation'] = Mission::query()->where([
|
||||
['state_id', '=', MissionStates::REQUEST_CREATED->value],
|
||||
['edare_shahri_id', '=', $user->edarate_shahri_id],
|
||||
['station_id', '=', $user->station_id],
|
||||
])->count();
|
||||
}
|
||||
if ($user->hasPermissionTo('manage-control-unit')) {
|
||||
$missions['control'] = Mission::query()->where([
|
||||
['state_id', '=', MissionStates::PENDING_CONFIRMATION->value],
|
||||
['edare_shahri_id', '=', $user->edarate_shahri_id],
|
||||
if ($user->hasPermissionTo('manage-transportation-unit-country')) {
|
||||
$missions['transportation'] = Mission::query()->where([
|
||||
['state_id', '=', MissionStates::REQUEST_CREATED->value],
|
||||
])->count();
|
||||
}
|
||||
if ($user->hasPermissionTo('manage-transportation-unit-province')) {
|
||||
$missions['transportation'] = Mission::query()->where([
|
||||
['state_id', '=', MissionStates::REQUEST_CREATED->value],
|
||||
['province_id', '=', $user->province_id],
|
||||
|
||||
])->count();
|
||||
}
|
||||
if ($user->hasPermissionTo('manage-transportation-unit-city')) {
|
||||
$missions['transportation'] = Mission::query()->where([
|
||||
['state_id', '=', MissionStates::REQUEST_CREATED->value],
|
||||
['city_id', '=', $user->city_id],
|
||||
|
||||
])->count();
|
||||
}
|
||||
|
||||
|
||||
if ($user->hasPermissionTo('manage-control-unit-station')) {
|
||||
$missions['control'] = Mission::query()
|
||||
->whereIn('state_id', [
|
||||
MissionStates::PENDING_CONFIRMATION->value,
|
||||
MissionStates::START_MISSION->value,
|
||||
])
|
||||
->where('station_id', $user->station_id)
|
||||
->count();
|
||||
}
|
||||
if ($user->hasPermissionTo('manage-control-unit-country')) {
|
||||
$missions['control'] = Mission::query()
|
||||
->whereIn('state_id', [
|
||||
MissionStates::PENDING_CONFIRMATION->value,
|
||||
MissionStates::START_MISSION->value,
|
||||
])->count();
|
||||
}
|
||||
if ($user->hasPermissionTo('manage-control-unit-province')) {
|
||||
$missions['control'] = Mission::query()
|
||||
->whereIn('state_id', [
|
||||
MissionStates::PENDING_CONFIRMATION->value,
|
||||
MissionStates::START_MISSION->value,
|
||||
])
|
||||
->where('province_id', '=', $user->province_id)
|
||||
->count();
|
||||
}
|
||||
if ($user->hasPermissionTo('manage-control-unit-city')) {
|
||||
$missions['control'] = Mission::query()
|
||||
->whereIn('state_id', [
|
||||
MissionStates::PENDING_CONFIRMATION->value,
|
||||
MissionStates::START_MISSION->value,
|
||||
])
|
||||
->where('city_id', '=', $user->city_id
|
||||
)->count();
|
||||
}
|
||||
|
||||
$missions['total'] = $missions['request_portal'] + $missions['transportation'] + $missions['control'];
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class FinishRequest extends FormRequest
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->mission->state_id == MissionStates::START_MISSION->value;
|
||||
return $this->mission->state_id === MissionStates::START_MISSION->value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,23 +55,12 @@ class FinishRequest extends FormRequest
|
||||
|
||||
$distance = $this->end_km - $mission->km;
|
||||
|
||||
if ($machine->car_group === 'سنگین') {
|
||||
|
||||
if ($distance > 15) {
|
||||
$validator->errors()->add(
|
||||
'end_km',
|
||||
'اختلاف کیلومتر برای خودروهای سنگین باید کمتر از 15 باشد.'
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ($distance > 1000) {
|
||||
$validator->errors()->add(
|
||||
'end_km',
|
||||
'اختلاف کیلومتر برای خودروهای سبک و نیمه سنگین باید کمتر از 1000 باشد.'
|
||||
);
|
||||
}
|
||||
if ($distance > $machine->distance_mission)
|
||||
{
|
||||
$validator->errors()->add(
|
||||
'end_km',
|
||||
'کیلومتر /ساعت کار از حد نصاب بیشتر هست.'
|
||||
);
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user