Add member deleteJob

This commit is contained in:
philipp lang 2022-11-16 22:08:08 +01:00
parent 4e43c88fca
commit 6e7601e3d4
3 changed files with 7 additions and 18 deletions

View File

@ -16,12 +16,11 @@ class DeleteJob implements ShouldQueue
use Queueable; use Queueable;
use SerializesModels; use SerializesModels;
public int $memberId; public int $namiId;
public Member $member;
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) public function handle(NamiSettings $setting)
{ {
$this->member = Member::find($this->memberId); $setting->login()->deleteMember($this->namiId);
if (!$this->member->hasNami) {
return;
}
$setting->login()->deleteMember($this->member->nami_id);
Member::withoutEvents(function () {
$this->member->update(['nami_id' => null]);
});
} }
} }

View File

@ -127,8 +127,8 @@ class MemberController extends Controller
public function destroy(Member $member): RedirectResponse public function destroy(Member $member): RedirectResponse
{ {
if ($member->has_nami) { if ($member->nami_id) {
DeleteJob::dispatch($member, auth()->user()); DeleteJob::dispatch($member->nami_id);
} }
$member->delete(); $member->delete();

View File

@ -103,7 +103,7 @@ class MemberRequest extends FormRequest
UpdateJob::dispatch($member->fresh()); UpdateJob::dispatch($member->fresh());
} }
if (!$this->input('has_nami') && null !== $member->nami_id) { if (!$this->input('has_nami') && null !== $member->nami_id) {
DeleteJob::dispatch($member); DeleteJob::dispatch($member->nami_id);
} }
} }
} }