add new column to safety
This commit is contained in:
@@ -37,13 +37,16 @@ class SupervisorController extends Controller
|
||||
return Excel::download(new SupervisorCartableReport($data['data']), $name);
|
||||
}
|
||||
|
||||
public function confirm(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse
|
||||
public function confirm(SafetyAndPrivacy $safetyAndPrivacy, Request $request): JsonResponse
|
||||
{
|
||||
$status_id = SafetyAndPrivacyStatus::CONFIRM->value;
|
||||
|
||||
$safetyAndPrivacy->update([
|
||||
'status' => $status_id,
|
||||
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
|
||||
'supervisor_description' => $request->supervisor_description,
|
||||
'supervisor_id' => auth()->user()->id,
|
||||
'supervisor_name' => auth()->user()->name,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
@@ -56,7 +59,9 @@ class SupervisorController extends Controller
|
||||
$safetyAndPrivacy->update([
|
||||
'status' => $status_id,
|
||||
'status_fa' => SafetyAndPrivacyStatus::name($status_id),
|
||||
'supervisor_description' => $request->supervisor_description
|
||||
'supervisor_description' => $request->supervisor_description,
|
||||
'supervisor_id' => auth()->user()->id,
|
||||
'supervisor_name' => auth()->user()->name,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
|
||||
@@ -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