add new column to safety
This commit is contained in:
@@ -91,33 +91,22 @@ class NotificationController extends Controller
|
||||
private function safetyAndPrivacyNotifications(): JsonResponse|array
|
||||
{
|
||||
$user = auth()->user();
|
||||
$safety_and_privacy = [
|
||||
'supervise_cnt' => 0,
|
||||
'step_one' => 0,
|
||||
'step_two' => 0,
|
||||
];
|
||||
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
|
||||
$supervise = SafetyAndPrivacy::query()
|
||||
->selectRaw('count(*) as cnt')
|
||||
->where([
|
||||
['is_finished', '=', 1],
|
||||
['status', '=', 0],
|
||||
])
|
||||
->get();
|
||||
$safety_and_privacy = array();
|
||||
|
||||
if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) {
|
||||
$safety_and_privacy['supervise_cnt'] = SafetyAndPrivacy::query()
|
||||
->where('is_finished', '=', 1)
|
||||
->where('status', '=', 0)
|
||||
->count();
|
||||
}
|
||||
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) {
|
||||
throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!'));
|
||||
|
||||
$supervise = SafetyAndPrivacy::query()
|
||||
$safety_and_privacy['supervise_cnt'] = SafetyAndPrivacy::query()
|
||||
->where('province_id', '=', $user->province_id)
|
||||
->selectRaw('count(*) as cnt')
|
||||
->where([
|
||||
['is_finished', '=', 1],
|
||||
['status', '=', 0],
|
||||
])
|
||||
->get();
|
||||
|
||||
->where('is_finished', '=', 1)
|
||||
->where('status', '=', 0)
|
||||
->count();
|
||||
}
|
||||
elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) {
|
||||
throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!'));
|
||||
@@ -125,17 +114,17 @@ class NotificationController extends Controller
|
||||
$activity = SafetyAndPrivacy::query()
|
||||
->where('edare_shahri_id', '=', $user->edarate_shahri_id)
|
||||
->selectRaw('count(*) as cnt, step')
|
||||
->where('is_finished', '=', 0)
|
||||
->groupby('step')
|
||||
->orderBy('step')
|
||||
->get();
|
||||
|
||||
$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;
|
||||
$safety_and_privacy['step_one'] = $step_one->cnt ?? 0;
|
||||
$safety_and_privacy['step_two'] = $step_two->cnt ?? 0;
|
||||
}
|
||||
|
||||
return $safety_and_privacy;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user