add notification for mission
This commit is contained in:
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\V3;
|
namespace App\Http\Controllers\V3;
|
||||||
|
|
||||||
|
use App\Enums\MissionStates;
|
||||||
use App\Exceptions\ProhibitedAction;
|
use App\Exceptions\ProhibitedAction;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Traits\ApiResponse;
|
use App\Http\Traits\ApiResponse;
|
||||||
use App\Models\EdarateOstani;
|
use App\Models\EdarateOstani;
|
||||||
|
use App\Models\Mission;
|
||||||
use App\Models\RoadItemsProject;
|
use App\Models\RoadItemsProject;
|
||||||
use App\Models\RoadObserved;
|
use App\Models\RoadObserved;
|
||||||
use App\Models\SafetyAndPrivacy;
|
use App\Models\SafetyAndPrivacy;
|
||||||
@@ -28,6 +30,7 @@ class NotificationController extends Controller
|
|||||||
'roadItem' => $this->roadItemNotifications(),
|
'roadItem' => $this->roadItemNotifications(),
|
||||||
'safetyAndPrivacy' => $this->safetyAndPrivacyNotifications(),
|
'safetyAndPrivacy' => $this->safetyAndPrivacyNotifications(),
|
||||||
'roadObserved' => $this->roadObservedNotifications(),
|
'roadObserved' => $this->roadObservedNotifications(),
|
||||||
|
'mission' => $this->missionNotification(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,4 +188,33 @@ class NotificationController extends Controller
|
|||||||
|
|
||||||
return $road_observations;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class ControlUnitService
|
|||||||
->whereIn('state_id', [
|
->whereIn('state_id', [
|
||||||
MissionStates::PENDING_CONFIRMATION->value, MissionStates::START_MISSION->value
|
MissionStates::PENDING_CONFIRMATION->value, MissionStates::START_MISSION->value
|
||||||
])
|
])
|
||||||
->where('edare_shahri_name', '=', Auth::user()->edarate_shahri_id);
|
->where('edare_shahri_id', '=', Auth::user()->edarate_shahri_id);
|
||||||
|
|
||||||
return DataTableFacade::run(
|
return DataTableFacade::run(
|
||||||
$query,
|
$query,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class TransportationUnitService
|
|||||||
{
|
{
|
||||||
$query = Mission::query()
|
$query = Mission::query()
|
||||||
->where('state_id', '=', MissionStates::REQUEST_CREATED->value)
|
->where('state_id', '=', MissionStates::REQUEST_CREATED->value)
|
||||||
->where('edare_shahri_name', '=', Auth::user()->edarate_shahri_id);
|
->where('edare_shahri_id', '=', Auth::user()->edarate_shahri_id);
|
||||||
|
|
||||||
return DataTableFacade::run(
|
return DataTableFacade::run(
|
||||||
$query,
|
$query,
|
||||||
|
|||||||
Reference in New Issue
Block a user