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 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);
}
}

View File

@ -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();

View File

@ -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);
}
}
}