From 6e7601e3d40447a70d8f42918176a0880973215d Mon Sep 17 00:00:00 2001 From: philipp lang Date: Wed, 16 Nov 2022 22:08:08 +0100 Subject: [PATCH] Add member deleteJob --- app/Member/DeleteJob.php | 19 ++++--------------- app/Member/MemberController.php | 4 ++-- app/Member/MemberRequest.php | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/app/Member/DeleteJob.php b/app/Member/DeleteJob.php index f55803a9..2325c852 100644 --- a/app/Member/DeleteJob.php +++ b/app/Member/DeleteJob.php @@ -16,12 +16,11 @@ class DeleteJob implements ShouldQueue use Queueable; use SerializesModels; - public int $memberId; - public Member $member; + public int $namiId; - public function __construct(Member $member) + public function __construct(int $namiId) { - $this->memberId = $member->id; + $this->namiId = $namiId; } /** @@ -31,16 +30,6 @@ class DeleteJob implements ShouldQueue */ public function handle(NamiSettings $setting) { - $this->member = Member::find($this->memberId); - - if (!$this->member->hasNami) { - return; - } - - $setting->login()->deleteMember($this->member->nami_id); - - Member::withoutEvents(function () { - $this->member->update(['nami_id' => null]); - }); + $setting->login()->deleteMember($this->namiId); } } diff --git a/app/Member/MemberController.php b/app/Member/MemberController.php index 676f8aef..8767bf14 100644 --- a/app/Member/MemberController.php +++ b/app/Member/MemberController.php @@ -127,8 +127,8 @@ class MemberController extends Controller public function destroy(Member $member): RedirectResponse { - if ($member->has_nami) { - DeleteJob::dispatch($member, auth()->user()); + if ($member->nami_id) { + DeleteJob::dispatch($member->nami_id); } $member->delete(); diff --git a/app/Member/MemberRequest.php b/app/Member/MemberRequest.php index bf75f66b..ee1a834b 100644 --- a/app/Member/MemberRequest.php +++ b/app/Member/MemberRequest.php @@ -103,7 +103,7 @@ class MemberRequest extends FormRequest UpdateJob::dispatch($member->fresh()); } if (!$this->input('has_nami') && null !== $member->nami_id) { - DeleteJob::dispatch($member); + DeleteJob::dispatch($member->nami_id); } } }