add new column to safety

This commit is contained in:
2025-04-27 14:24:37 +03:30
parent d0b9803d8d
commit 933a5165e7
5 changed files with 32 additions and 30 deletions

View File

@@ -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();

View File

@@ -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;
}

View File

@@ -43,7 +43,9 @@ class SafetyAndPrivacy extends Model
'supervisor_description',
'status_fa',
'need_judiciary',
'operator_description'
'operator_description',
'supervisor_name',
'supervisor_id'
];
public $table = "safety_and_privacy";

View File

@@ -49,7 +49,7 @@ class SafetyAndPrivacyTableService
$user = auth()->user();
$fields = [
'id','lat','lon', 'recognize_picture','action_picture','created_at','step', 'final_description', 'province_fa',
'id','lat','lon', 'recognize_picture','action_picture','created_at','status', 'final_description', 'province_fa',
'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', 'edare_shahri_name',
'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description', 'operator_description'
];

View File

@@ -19,6 +19,8 @@ return new class extends Migration
$table->string('supervisor_description')->nullable();
$table->string('final_description')->nullable();
$table->boolean('need_judiciary')->nullable();
$table->integer('supervisor_id')->nullable();
$table->string('supervisor_name')->nullable();
$table->text('judiciary_document')->nullable()->change();
$table->dateTime('judiciary_document_upload_date')->nullable()->change();
});
@@ -30,7 +32,11 @@ return new class extends Migration
public function down(): void
{
Schema::table('safety_and_privacy', function (Blueprint $table) {
$table->dropColumn(['status', 'final_description', 'is_finished', 'supervisor_description', 'status_fa', 'need_judiciary', 'operator_description']);
$table->dropColumn([
'status', 'final_description', 'is_finished',
'supervisor_description', 'status_fa', 'need_judiciary',
'operator_description', 'supervisor_name', 'supervisor_id',
]);
$table->text('judiciary_document')->change();
$table->dateTime('judiciary_document_upload_date')->change();
});