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) {