add notification for mission
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Http\Controllers\V3;
|
||||
|
||||
use App\Enums\MissionStates;
|
||||
use App\Exceptions\ProhibitedAction;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Traits\ApiResponse;
|
||||
use App\Models\EdarateOstani;
|
||||
use App\Models\Mission;
|
||||
use App\Models\RoadItemsProject;
|
||||
use App\Models\RoadObserved;
|
||||
use App\Models\SafetyAndPrivacy;
|
||||
@@ -28,6 +30,7 @@ class NotificationController extends Controller
|
||||
'roadItem' => $this->roadItemNotifications(),
|
||||
'safetyAndPrivacy' => $this->safetyAndPrivacyNotifications(),
|
||||
'roadObserved' => $this->roadObservedNotifications(),
|
||||
'mission' => $this->missionNotification(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -185,4 +188,33 @@ class NotificationController extends Controller
|
||||
|
||||
return $road_observations;
|
||||
}
|
||||
|
||||
public function missionNotification(): array
|
||||
{
|
||||
$user = auth()->user();
|
||||
$missions = [
|
||||
'request_portal' => Mission::query()
|
||||
->where([
|
||||
['state_id', '=', MissionStates::REJECT_BY_TRANSPORTATION->value],
|
||||
['user_id', '=', $user->id]
|
||||
])->count(),
|
||||
'transportation' => 0,
|
||||
'control' => 0,
|
||||
];
|
||||
|
||||
if ($user->hasPermissionTo('manage-transportation-unit')) {
|
||||
$missions['transportation'] = Mission::query()->where([
|
||||
['state_id', '=', MissionStates::REQUEST_CREATED->value],
|
||||
['edare_shahri_id', '=', $user->edarate_shahri_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]
|
||||
])->count();
|
||||
}
|
||||
|
||||
return $missions;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user