diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php index 36d41115..06b03021 100644 --- a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php @@ -101,18 +101,27 @@ class SafetyAndPrivacyController extends Controller { $user = auth()->user(); - DB::transaction(function () use ($request, $safetyAndPrivacy, $user) - { + DB::transaction(function () use ($request, $safetyAndPrivacy, $user) { + + $need_judiciary = $request->need_judiciary; + $judiciary_document = []; - foreach ($request->judiciary_document as $index => $file) { - $judiciary_document[] = FileFacade::save($file, "safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document"); + if ($need_judiciary) { + foreach ($request->judiciary_document as $index => $file) { + $judiciary_document[] = FileFacade::save( + $file, + "safety_and_privacy/{$safetyAndPrivacy->id}/judiciary_document" + ); + } } + $step = SafetyAndPrivacySteps::MOSTANADAT_GAZAEI->value; $safetyAndPrivacy->update([ - 'judiciary_document' => serialize($judiciary_document), - 'judiciary_document_upload_date' => now(), 'step' => $step, 'step_fa' => SafetyAndPrivacySteps::name($step), + 'judiciary_document' => $need_judiciary ? serialize($judiciary_document) : null, + 'judiciary_document_upload_date' => $need_judiciary ? now() : null, + 'need_judiciary' => $need_judiciary, ]); $user->addActivityComplete(1135); diff --git a/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php b/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php index 5d130d51..78e471ad 100644 --- a/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php +++ b/app/Http/Requests/V3/SafetyAndPrivacy/SecondStepStoreRequest.php @@ -22,6 +22,7 @@ class SecondStepStoreRequest extends FormRequest public function rules(): array { return [ + 'need_judiciary' => 'required|boolean', 'judiciary_document' => 'required|array', 'judiciary_document.*' => 'file', ]; 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 d63218ce..e78b6af7 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 @@ -17,6 +17,9 @@ return new class extends Migration $table->string('status_fa')->nullable(); $table->string('supervisor_description')->nullable(); $table->string('final_description')->nullable(); + $table->boolean('need_judiciary')->nullable(); + $table->text('judiciary_document')->nullable()->change(); + $table->dateTime('judiciary_document_upload_date')->nullable()->change(); }); } @@ -26,7 +29,9 @@ 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']); + $table->dropColumn(['status', 'final_description', 'is_finished', 'supervisor_description', 'status_fa', 'need_judiciary']); + $table->text('judiciary_document')->change(); + $table->dateTime('judiciary_document_upload_date')->change(); }); } };