feat: add archived application text field to EinundzwanzigPleb model

This commit introduces a new field `archived_application_text` to the EinundzwanzigPleb model. The application text of a Pleb is now archived before the association status is updated and the application text is set to null. A migration file is also added to update the database schema.
This commit is contained in:
fsociety
2024-09-30 19:16:06 +02:00
parent f91313b6f5
commit 265ed40839
2 changed files with 29 additions and 0 deletions

View File

@@ -140,8 +140,10 @@ final class EinundzwanzigPlebTable extends PowerGridComponent
{
$pleb = EinundzwanzigPleb::query()->findOrFail($rowId);
$for = $pleb->application_for;
$text = $pleb->application_text;
$pleb->association_status = AssociationStatus::from($for);
$pleb->application_for = null;
$pleb->archived_application_text = $text;
$pleb->application_text = null;
$pleb->save();

View File

@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('einundzwanzig_plebs', function (Blueprint $table) {
$table->text('archived_application_text')->nullable()->after('application_text');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('einundzwanzig_plebs', function (Blueprint $table) {
//
});
}
};