Add participants parent id

This commit is contained in:
philipp lang 2024-03-08 01:26:40 +01:00
parent 43846d1703
commit a0842afd47
3 changed files with 5 additions and 1 deletions

View File

@ -119,7 +119,7 @@ class NamiField extends Field
} }
$data[$this->key] = []; $data[$this->key] = [];
$form->participants()->create(['data' => $data, 'mitgliedsnr' => $memberData['id']]); $form->participants()->create(['data' => $data, 'mitgliedsnr' => $memberData['id'], 'parent_id' => $participant->id]);
} }
} }

View File

@ -17,6 +17,7 @@ return new class extends Migration
$table->id(); $table->id();
$table->json('data'); $table->json('data');
$table->foreignId('form_id'); $table->foreignId('form_id');
$table->foreignId('parent_id', 'participants')->nullable();
$table->string('mitgliedsnr')->nullable(); $table->string('mitgliedsnr')->nullable();
$table->timestamps(); $table->timestamps();
}); });

View File

@ -308,6 +308,7 @@ class FormRegisterActionTest extends FormTestCase
$this->register($form, ['email' => 'max@muster.de'])->assertOk(); $this->register($form, ['email' => 'max@muster.de'])->assertOk();
$this->assertNull($form->participants->first()->mitgliedsnr); $this->assertNull($form->participants->first()->mitgliedsnr);
$this->assertNull($form->participants->first()->parent_id);
} }
// --------------------------- NamiField Tests --------------------------- // --------------------------- NamiField Tests ---------------------------
@ -329,6 +330,8 @@ class FormRegisterActionTest extends FormTestCase
$this->assertEquals([['id' => '5505'], ['id' => '5506']], $form->participants->get(0)->data['members']); $this->assertEquals([['id' => '5505'], ['id' => '5506']], $form->participants->get(0)->data['members']);
$this->assertEquals([], $form->participants->get(1)->data['members']); $this->assertEquals([], $form->participants->get(1)->data['members']);
$this->assertEquals([], $form->participants->get(2)->data['members']); $this->assertEquals([], $form->participants->get(2)->data['members']);
$this->assertEquals($form->participants->get(0)->id, $form->participants->get(2)->parent_id);
$this->assertEquals($form->participants->get(0)->id, $form->participants->get(1)->parent_id);
} }
protected function memberMatchingDataProvider(): Generator protected function memberMatchingDataProvider(): Generator