diff --git a/app/Form/Actions/FormStoreAction.php b/app/Form/Actions/FormStoreAction.php index afa9ddb8..cdc6b020 100644 --- a/app/Form/Actions/FormStoreAction.php +++ b/app/Form/Actions/FormStoreAction.php @@ -36,6 +36,8 @@ class FormStoreAction 'needs_prevention' => 'present|boolean', 'prevention_text' => 'array', 'prevention_conditions' => 'array', + 'zip' => 'present|nullable|string', + 'location' => 'present|nullable|string', ]; } diff --git a/app/Form/Actions/FormUpdateAction.php b/app/Form/Actions/FormUpdateAction.php index e921e512..3fcc91c1 100644 --- a/app/Form/Actions/FormUpdateAction.php +++ b/app/Form/Actions/FormUpdateAction.php @@ -3,7 +3,6 @@ namespace App\Form\Actions; use App\Form\Models\Form; -use App\Lib\Editor\Condition; use App\Lib\Events\Succeeded; use Illuminate\Http\JsonResponse; use Lorisleiva\Actions\Concerns\AsAction; @@ -36,6 +35,8 @@ class FormUpdateAction 'needs_prevention' => 'present|boolean', 'prevention_text' => 'array', 'prevention_conditions' => 'array', + 'location' => 'present|nullable|string', + 'zip' => 'present|nullable|string', ]; } diff --git a/database/migrations/2025_07_04_210136_create_forms_zip_column.php b/database/migrations/2025_07_04_210136_create_forms_zip_column.php new file mode 100644 index 00000000..8d485710 --- /dev/null +++ b/database/migrations/2025_07_04_210136_create_forms_zip_column.php @@ -0,0 +1,30 @@ +string('zip')->nullable()->after('name'); + $table->string('location')->nullable()->after('name'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('forms', function (Blueprint $table) { + $table->dropColumn('zip'); + $table->dropColumn('location'); + }); + } +}; diff --git a/tests/Feature/Form/FormRequest.php b/tests/Feature/Form/FormRequest.php index a255d4b4..6d4bbe8d 100644 --- a/tests/Feature/Form/FormRequest.php +++ b/tests/Feature/Form/FormRequest.php @@ -53,6 +53,8 @@ class FormRequest extends RequestFactory 'export' => ExportData::from([])->toArray(), 'needs_prevention' => $this->faker->boolean(), 'prevention_text' => EditorRequestFactory::new()->create(), + 'zip' => (string) $this->faker->numberBetween(10, 6666), + 'location' => (string) $this->faker->city(), 'prevention_conditions' => Condition::defaults()->toArray(), ]; } diff --git a/tests/Feature/Form/FormStoreActionTest.php b/tests/Feature/Form/FormStoreActionTest.php index fe889295..29930dc7 100644 --- a/tests/Feature/Form/FormStoreActionTest.php +++ b/tests/Feature/Form/FormStoreActionTest.php @@ -32,6 +32,8 @@ it('testItStoresForm', function () { ->mailTop(EditorRequestFactory::new()->text(11, 'lala')) ->mailBottom(EditorRequestFactory::new()->text(12, 'lalab')) ->headerImage('htzz.jpg') + ->zip('12345') + ->location('Solingen') ->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()->namiType(NamiType::BIRTHDAY)->forMembers(false)->hint('hhh')])]) ->fake(); @@ -55,6 +57,8 @@ it('testItStoresForm', function () { $this->assertFalse($form->config->sections->get(0)->fields->get(0)->forMembers); $this->assertCount(1, $form->getMedia('headerImage')); $this->assertEquals('formname.jpg', $form->getMedia('headerImage')->first()->file_name); + $this->assertEquals('Solingen', $form->location); + $this->assertEquals('12345', $form->zip); Event::assertDispatched(Succeeded::class, fn(Succeeded $event) => $event->message === 'Veranstaltung gespeichert.'); $this->assertFrontendCacheCleared(); }); @@ -71,14 +75,16 @@ it('testItStoresDefaultSorting', function () { $this->assertFalse(false, $form->meta['sorting']['direction']); }); -it('testRegistrationDatesCanBeNull', function () { +it('testValuesCanBeNull', function () { $this->login()->loginNami()->withoutExceptionHandling(); - $this->postJson(route('form.store'), FormRequest::new()->registrationFrom(null)->registrationUntil(null)->create())->assertOk(); + $this->postJson(route('form.store'), FormRequest::new()->registrationFrom(null)->registrationUntil(null)->location(null)->zip(null)->create())->assertOk(); $this->assertDatabaseHas('forms', [ 'registration_until' => null, 'registration_from' => null, + 'zip' => null, + 'location' => null, ]); }); diff --git a/tests/Feature/Form/FormUpdateActionTest.php b/tests/Feature/Form/FormUpdateActionTest.php index 3c549685..b42a45c8 100644 --- a/tests/Feature/Form/FormUpdateActionTest.php +++ b/tests/Feature/Form/FormUpdateActionTest.php @@ -118,6 +118,19 @@ it('testItUpdatesActiveState', function () { $this->assertTrue($form->fresh()->is_active); }); +it('updates zip and location', function () { + $this->login()->loginNami()->withoutExceptionHandling(); + $form = Form::factory()->create(); + $request = FormRequest::new()->zip('12345')->location('Musterstadt')->create(); + + $this->patchJson(route('form.update', ['form' => $form]), $request)->assertOk(); + test()->assertDatabaseHas('forms', [ + 'id' => $form->id, + 'zip' => '12345', + 'location' => 'Musterstadt', + ]); +}); + it('testItUpdatesPrivateState', function () { $this->login()->loginNami()->withoutExceptionHandling(); $form = Form::factory()->create();