From 651d69a538bf83c7515c965f6c616cd7a4e2f2ee Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 31 May 2022 22:08:52 +0200 Subject: [PATCH] Fixed: Dont update member when no nami fields are filled --- app/Member/Member.php | 2 ++ app/Member/MemberRequest.php | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Member/Member.php b/app/Member/Member.php index b1943c90..4bcacc0b 100644 --- a/app/Member/Member.php +++ b/app/Member/Member.php @@ -37,6 +37,8 @@ class Member extends Model public $guarded = []; + public static array $namiFields = ['firstname', 'lastname', 'joined_at', 'birthday', 'send_newspaper', 'address', 'zip', 'location', 'nickname', 'other_country', 'further_address', 'main_phone', 'mobile_phone', 'work_phone', 'fax', 'email', 'email_parents', 'gender_id', 'confession_id', 'region_id', 'country_id', 'fee_id', 'nationality_id']; + public $dates = ['try_created_at', 'joined_at', 'birthday']; public $casts = [ diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index 0464b277..9df8de6b 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -79,12 +79,16 @@ class MemberRequest extends FormRequest public function persistUpdate(Member $member): void { - $member->update($this->validated()); + $member->fill($this->validated()); + + $namiSync = $member->isDirty(Member::$namiFields); + + $member->save(); if ($this->input('has_nami') && null === $member->nami_id) { CreateJob::dispatch($member); } - if ($this->input('has_nami') && null !== $member->nami_id) { + if ($this->input('has_nami') && null !== $member->nami_id && $namiSync) { UpdateJob::dispatch($member->fresh()); } if (!$this->input('has_nami') && null !== $member->nami_id) {