Compare commits
2 Commits
c89973032b
...
dc832503b4
Author | SHA1 | Date |
---|---|---|
|
dc832503b4 | |
|
3a96b00307 |
|
@ -36,15 +36,7 @@ class MemberController extends Controller
|
|||
session()->put('title', 'Mitglied erstellen');
|
||||
|
||||
return \Inertia::render('member/VForm', [
|
||||
'data' => [
|
||||
'country_id' => Country::default(),
|
||||
'efz' => null,
|
||||
'ps_at' => null,
|
||||
'without_education_at' => null,
|
||||
'without_efz_at' => null,
|
||||
'more_ps_at' => null,
|
||||
'joined_at' => now()->format('Y-m-d'),
|
||||
],
|
||||
'data' => MemberResource::defaultModel(),
|
||||
'mode' => 'create',
|
||||
'meta' => MemberResource::meta(),
|
||||
]);
|
||||
|
|
|
@ -41,6 +41,10 @@ class MemberRequest extends FormRequest
|
|||
'first_subactivity' => 'exclude|required',
|
||||
] : [],
|
||||
'subscription_id' => Rule::requiredIf(function () {
|
||||
if (!$this->input('has_nami')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('POST' != $this->method()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -149,4 +149,51 @@ class MemberResource extends JsonResource
|
|||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function defaultModel(): array
|
||||
{
|
||||
return [
|
||||
'gender_id' => null,
|
||||
'salutation' => '',
|
||||
'nationality_id' => null,
|
||||
'firstname' => '',
|
||||
'lastname' => '',
|
||||
'address' => '',
|
||||
'further_address' => '',
|
||||
'zip' => '',
|
||||
'location' => '',
|
||||
'birthday' => '',
|
||||
'region_id' => null,
|
||||
'country_id' => Country::default(),
|
||||
'other_country' => '',
|
||||
'main_phone' => '',
|
||||
'mobile_phone' => '',
|
||||
'work_phone' => '',
|
||||
'children_phone' => '',
|
||||
'email' => '',
|
||||
'email_parents' => '',
|
||||
'fax' => '',
|
||||
'letter_address' => '',
|
||||
'bill_kind' => null,
|
||||
'subscription_id' => null,
|
||||
'has_nami' => false,
|
||||
'send_newspaper' => false,
|
||||
'joined_at' => now()->format('Y-m-d'),
|
||||
'comment' => '',
|
||||
'first_activity_id' => null,
|
||||
'first_subactivity_id' => null,
|
||||
'efz' => null,
|
||||
'ps_at' => null,
|
||||
'more_ps_at' => null,
|
||||
'without_education_at' => null,
|
||||
'without_efz_at' => null,
|
||||
'has_vk' => false,
|
||||
'has_svk' => false,
|
||||
'multiply_pv' => false,
|
||||
'multiply_more_pv' => false,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,14 @@ class CreateTest extends TestCase
|
|||
$this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}");
|
||||
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
|
||||
|
||||
$this->assertInertiaHas(['efz' => null, 'ps_at' => null, 'more_ps_at' => null, 'without_education_at' => null, 'without_efz_at' => null], $response, 'data');
|
||||
$this->assertInertiaHas([
|
||||
'efz' => null,
|
||||
'ps_at' => null,
|
||||
'more_ps_at' => null,
|
||||
'without_education_at' => null,
|
||||
'without_efz_at' => null,
|
||||
'address' => '',
|
||||
], $response, 'data');
|
||||
}
|
||||
|
||||
public function testItDoesntDisplayActivitiesAndSubactivitiesNotInNami(): void
|
||||
|
|
|
@ -75,7 +75,8 @@ class StoreTest extends TestCase
|
|||
'salutation' => 'Doktor',
|
||||
'comment' => 'Lorem bla',
|
||||
]);
|
||||
NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(fn (Member $memberParam, Activity $activityParam, Subactivity $subactivityParam) => $memberParam->is($member)
|
||||
NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(
|
||||
fn (Member $memberParam, Activity $activityParam, Subactivity $subactivityParam) => $memberParam->is($member)
|
||||
&& $activityParam->is($activity)
|
||||
&& $subactivityParam->is($subactivity)
|
||||
)->once();
|
||||
|
@ -153,7 +154,7 @@ class StoreTest extends TestCase
|
|||
'zip' => null,
|
||||
'location' => null,
|
||||
'joined_at' => null,
|
||||
]));
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
$this->assertDatabaseHas('members', [
|
||||
'nationality_id' => null,
|
||||
'birthday' => null,
|
||||
|
@ -164,6 +165,20 @@ class StoreTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function testItDoesntNeedSubscription(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
|
||||
$this
|
||||
->post('/member', $this->attributes([
|
||||
'has_nami' => false,
|
||||
'subscription_id' => null,
|
||||
]))->assertSessionDoesntHaveErrors();
|
||||
$this->assertDatabaseHas('members', [
|
||||
'subscription_id' => null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function testItRequiresFields(): void
|
||||
{
|
||||
$this->login()->loginNami();
|
||||
|
|
Loading…
Reference in New Issue