From 8137d37c73c663fd1c58a6fcc96ebb5ddcc12a15 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 28 Apr 2022 23:20:41 +0200 Subject: [PATCH] =?UTF-8?q?Add=20pr=C3=A4vention?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierrc | 7 + app/Member/Member.php | 6 +- app/Member/MemberRequest.php | 2 +- app/Member/MemberResource.php | 8 + ...03444_create_members_prevention_column.php | 37 ++++ resources/js/views/member/VForm.vue | 208 +++++++++++++++--- tests/Feature/Member/UpdateTest.php | 22 +- 7 files changed, 255 insertions(+), 35 deletions(-) create mode 100644 .prettierrc create mode 100644 database/migrations/2022_04_28_203444_create_members_prevention_column.php diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..a833d36d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "printWidth": 120, + "singleQuote": true, + "tabWidth": 4, + "quoteProps": "consistent", + "bracketSpacing": false +} diff --git a/app/Member/Member.php b/app/Member/Member.php index f9f0c5f0..46b7909d 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -34,7 +34,7 @@ class Member extends Model use Notifiable; use HasFactory; - public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'group_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'subscription_id', 'region_id', 'gender_id', 'confession_id', 'letter_address', 'bill_kind_id', 'version', 'first_subactivity_id', 'first_activity_id', 'confirmed_at', 'children_phone', 'efz']; + public $fillable = ['firstname', 'lastname', 'nickname', 'other_country', 'birthday', 'joined_at', 'send_newspaper', 'address', 'further_address', 'zip', 'location', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'nami_id', 'group_id', 'letter_address', 'country_id', 'way_id', 'nationality_id', 'subscription_id', 'region_id', 'gender_id', 'confession_id', 'letter_address', 'bill_kind_id', 'version', 'first_subactivity_id', 'first_activity_id', 'confirmed_at', 'children_phone', 'efz', 'ps_at', 'more_ps_at', 'has_svk', 'has_vk', 'without_education_at', 'without_efz_at', 'multiply_pv', 'multiply_more_pv']; public $dates = ['try_created_at', 'joined_at', 'birthday']; @@ -48,6 +48,10 @@ class Member extends Model 'confession_id' => 'integer', 'nami_id' => 'integer', 'is_confirmed' => 'boolean', + 'has_svk' => 'boolean', + 'has_vk' => 'boolean', + 'multiply_pv' => 'boolean', + 'multiply_more_pv' => 'boolean', ]; public function scopeSearch(Builder $q, ?string $text): Builder diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index c1a4a779..3cf5ea43 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -77,7 +77,7 @@ class MemberRequest extends FormRequest CreateJob::dispatch($member, auth()->user()); } if ($this->input('has_nami') && null !== $member->nami_id) { - UpdateJob::dispatch($member, auth()->user()); + UpdateJob::dispatch($member->fresh(), auth()->user()); } if (!$this->input('has_nami') && null !== $member->nami_id) { DeleteJob::dispatch($member, auth()->user()); diff --git a/app/Member/MemberResource.php b/app/Member/MemberResource.php index 3ecedb63..5878fc34 100644 --- a/app/Member/MemberResource.php +++ b/app/Member/MemberResource.php @@ -63,6 +63,14 @@ class MemberResource extends JsonResource 'courses' => CourseResource::collection($this->whenLoaded('courses')), 'efz' => $this->efz, 'efz_link' => $this->getEfzLink(), + 'ps_at' => $this->ps_at, + 'more_ps_at' => $this->more_ps_at, + 'has_svk' => $this->has_svk, + 'has_vk' => $this->has_vk, + 'without_education_at' => $this->without_education_at, + 'without_efz_at' => $this->without_efz_at, + 'multiply_pv' => $this->multiply_pv, + 'multiply_more_pv' => $this->multiply_more_pv, ]; } } diff --git a/database/migrations/2022_04_28_203444_create_members_prevention_column.php b/database/migrations/2022_04_28_203444_create_members_prevention_column.php new file mode 100644 index 00000000..ac8599f8 --- /dev/null +++ b/database/migrations/2022_04_28_203444_create_members_prevention_column.php @@ -0,0 +1,37 @@ +date('ps_at')->nullable(); + $table->date('more_ps_at')->nullable(); + $table->date('without_education_at')->nullable(); + $table->date('without_efz_at')->nullable(); + $table->boolean('has_svk')->default(false); + $table->boolean('has_vk')->default(false); + $table->boolean('multiply_pv')->default(false); + $table->boolean('multiply_more_pv')->default(false); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('members', function (Blueprint $table) { + }); + } +}; diff --git a/resources/js/views/member/VForm.vue b/resources/js/views/member/VForm.vue index 1e334c77..fb0b3a6a 100644 --- a/resources/js/views/member/VForm.vue +++ b/resources/js/views/member/VForm.vue @@ -3,10 +3,26 @@
- +
- +
@@ -23,14 +39,44 @@ - - - + + +

Erste Gruppierung

- - + +
@@ -43,35 +89,138 @@
- + +
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+ + + + +
- - - -
- - -
+ + +
diff --git a/tests/Feature/Member/UpdateTest.php b/tests/Feature/Member/UpdateTest.php index 1e6d6f69..b33dca2d 100644 --- a/tests/Feature/Member/UpdateTest.php +++ b/tests/Feature/Member/UpdateTest.php @@ -38,7 +38,6 @@ class UpdateTest extends TestCase $this->fakeRequest(); $response = $this - ->from("/member/{$member->id}") ->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::'])); Http::assertSent(fn ($request) => 'PUT' === $request->method() @@ -84,9 +83,28 @@ class UpdateTest extends TestCase $response = $this ->from("/member/{$member->id}") - ->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['efz' => '2021-02-03', 'has_nami' => true])); + ->patch("/member/{$member->id}", array_merge($member->getAttributes(), [ + 'ps_at' => '2021-02-01', + 'more_ps_at' => '2021-02-02', + 'has_svk' => true, + 'has_vk' => true, + 'efz' => '2021-02-03', + 'without_education_at' => '2021-02-04', + 'without_efz_at' => '2021-02-05', + 'has_nami' => true, + 'multiply_pv' => true, + 'multiply_more_pv' => true, + ])); + $this->assertEquals('2021-02-01', $member->fresh()->ps_at); + $this->assertEquals('2021-02-02', $member->fresh()->more_ps_at); + $this->assertTrue($member->fresh()->has_svk); + $this->assertTrue($member->fresh()->has_vk); + $this->assertTrue($member->fresh()->multiply_pv); + $this->assertTrue($member->fresh()->multiply_more_pv); $this->assertEquals('2021-02-03', $member->fresh()->efz); + $this->assertEquals('2021-02-04', $member->fresh()->without_education_at); + $this->assertEquals('2021-02-05', $member->fresh()->without_efz_at); } private function member(): Member