diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorController.php index bce8f08e..650a6a93 100644 --- a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorController.php +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacy/OperatorController.php @@ -120,6 +120,7 @@ class OperatorController extends Controller 'judiciary_document' => $need_judiciary ? serialize($judiciary_document) : null, 'judiciary_document_upload_date' => $need_judiciary ? now() : null, 'need_judiciary' => $need_judiciary, + 'operator_description' => $request->operator_description, ]); $user->addActivityComplete(1135); diff --git a/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php b/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php index 78e471ad..dc88a0b6 100644 --- a/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php +++ b/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php @@ -23,7 +23,8 @@ class SecondStepStoreRequest extends FormRequest { return [ 'need_judiciary' => 'required|boolean', - 'judiciary_document' => 'required|array', + 'operator_description' => 'required_if:need_judiciary,0|string', + 'judiciary_document' => 'required_if:need_judiciary,1|array', 'judiciary_document.*' => 'file', ]; } diff --git a/app/Services/Cartables/SafetyAndPrivacyTableService.php b/app/Services/Cartables/SafetyAndPrivacyTableService.php index 4e651ef4..f5d07ad4 100644 --- a/app/Services/Cartables/SafetyAndPrivacyTableService.php +++ b/app/Services/Cartables/SafetyAndPrivacyTableService.php @@ -28,42 +28,40 @@ class SafetyAndPrivacyTableService 'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description' ]; - if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable')) { - $query = SafetyAndPrivacy::query()->select($fields); - } - elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) { - throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); + throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!')); - $query = SafetyAndPrivacy::query()->where('province_id', '=', $user->province_id)->select($fields); - } - elseif ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-edarate-shahri')) { - throw_if(is_null($user->edarate_shahri_id), new ProhibitedAction('اداره ای برای شما در سامانه ثبت نشده است!')); - - $query = SafetyAndPrivacy::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id); - } + $query = SafetyAndPrivacy::query()->where('edare_shahri_id', '=', $user->edarate_shahri_id); return DataTableFacade::run( $query, $request, allowedFilters: ['*'], - allowedSortings: ['*'] + allowedSortings: ['*'], + allowedSelects: $fields ); } + /** + * @throws Throwable + */ public function supervisorDataTable(Request $request) { $user = auth()->user(); - $fields = ['id','lat','lon','province_id','province_fa','city_id','city_fa','edare_shahri_id','edare_shahri_name', - 'recognize_picture','action_picture','operator_id','operator_name','way_id','created_at','updated_at','step', - 'info_id','info_fa','activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', - 'step_fa', 'axis_type_id', 'axis_type_name', 'action_date' + $fields = [ + 'id','lat','lon', 'recognize_picture','action_picture','created_at','step', 'final_description', + 'info_fa', 'activity_date_time', 'action_picture_document_upload_date', 'judiciary_document_upload_date', + 'step_fa', 'axis_type_id', 'axis_type_name', 'action_date', 'is_finished', 'status_fa', 'supervisor_description' ]; - $query = SafetyAndPrivacy::query()->where([ - ['province_id', '=', $user->province_id], - ['is_finished', '=', 1] - ]); + $query = SafetyAndPrivacy::query()->where('is_finished', '=', 1); + + if ($user->hasPermissionTo('show-safety-and-privacy-operator-cartable-province')) + { + throw_if(is_null($user->province_id), new ProhibitedAction('استانی برای شما در سامانه ثبت نشده است!')); + + $query = $query->where('province_id', '=', $user->province_id); + } return DataTableFacade::run( $query, diff --git a/database/migrations/2025_04_22_100327_add_column_to_safety_and_privacy_table.php b/database/migrations/2025_04_22_100327_add_column_to_safety_and_privacy_table.php index e78b6af7..d747836d 100644 --- a/database/migrations/2025_04_22_100327_add_column_to_safety_and_privacy_table.php +++ b/database/migrations/2025_04_22_100327_add_column_to_safety_and_privacy_table.php @@ -15,6 +15,7 @@ return new class extends Migration $table->boolean('is_finished')->nullable(); $table->integer('status')->nullable(); $table->string('status_fa')->nullable(); + $table->string('operator_description')->nullable(); $table->string('supervisor_description')->nullable(); $table->string('final_description')->nullable(); $table->boolean('need_judiciary')->nullable();