Add mitgliedsnr column to sub member
This commit is contained in:
parent
c9cbf86626
commit
5f47729bb6
|
@ -126,7 +126,7 @@ class NamiField extends Field
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[$this->key] = [];
|
$data[$this->key] = [];
|
||||||
$form->participants()->create(['data' => $data]);
|
$form->participants()->create(['data' => $data, 'mitgliedsnr' => $memberData['id']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,4 +45,9 @@ class ParticipantFactory extends Factory
|
||||||
{
|
{
|
||||||
return $this->state(['data' => $data]);
|
return $this->state(['data' => $data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function nr(int $number): self
|
||||||
|
{
|
||||||
|
return $this->state(['mitgliedsnr' => $number]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('participants', function (Blueprint $table) {
|
||||||
|
$table->string('mitgliedsnr')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('participants', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('mitgliedsnr');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -425,6 +425,20 @@ class FormRegisterActionTest extends FormTestCase
|
||||||
$this->register($form, ['members' => null])->assertJsonValidationErrors(['members']);
|
$this->register($form, ['members' => null])->assertJsonValidationErrors(['members']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParticipantsHaveRelationToActualMember(): void
|
||||||
|
{
|
||||||
|
$this->login()->loginNami();
|
||||||
|
$member = $this->createMember(['mitgliedsnr' => '5505']);
|
||||||
|
$form = Form::factory()
|
||||||
|
->sections([FormtemplateSectionRequest::new()->fields([
|
||||||
|
$this->namiField('members'),
|
||||||
|
])])
|
||||||
|
->create();
|
||||||
|
|
||||||
|
$this->register($form, ['members' => [['id' => '5505']]])->assertOk();
|
||||||
|
$this->assertEquals('5505', $form->participants->get(1)->mitgliedsnr);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $attributes
|
* @param array<string, mixed> $attributes
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue