Fixed: Dont update member when no nami fields are filled
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2022-05-31 22:08:52 +02:00
parent 364952eae9
commit 651d69a538
2 changed files with 8 additions and 2 deletions

View File

@ -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 = [

View File

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