add notification count for supervise

This commit is contained in:
2025-04-27 13:55:29 +03:30
parent 9a0f152244
commit d0b9803d8d
4 changed files with 34 additions and 16 deletions

View File

@@ -91,23 +91,31 @@ class NotificationController extends Controller
private function safetyAndPrivacyNotifications(): JsonResponse|array
{
$user = auth()->user();
$safety_and_privacy = array();
$safety_and_privacy = [
'supervise_cnt' => 0,
'step_one' => 0,
'step_two' => 0,
];
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
$activity = SafetyAndPrivacy::query()
->selectRaw('count(*) as cnt, step')
->groupby('step')
->orderBy('step')
$supervise = SafetyAndPrivacy::query()
->selectRaw('count(*) as cnt')
->where([
['is_finished', '=', 1],
['status', '=', 0],
])
->get();
}
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) {
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
$activity = SafetyAndPrivacy::query()
$supervise = SafetyAndPrivacy::query()
->where('province_id', '=', $user->province_id)
->selectRaw('count(*) as cnt, step')
->groupby('step')
->orderBy('step')
->selectRaw('count(*) as cnt')
->where([
['is_finished', '=', 1],
['status', '=', 0],
])
->get();
}
@@ -120,13 +128,14 @@ class NotificationController extends Controller
->groupby('step')
->orderBy('step')
->get();
}
$step_one = $activity->where('step', '=', 1)->first();
$step_two = $activity->where('step', '=', 2)->first();
$step_one = $activity->where('step', '=', 1)->first();
$step_two = $activity->where('step', '=', 2)->first();
}
$safety_and_privacy['step_one'] = $step_one->cnt ?? 0;
$safety_and_privacy['step_two'] = $step_two->cnt ?? 0;
$safety_and_privacy['supervise_cnt'] = $supervise->cnt ?? 0;
return $safety_and_privacy;
}