Add member deleteJob
This commit is contained in:
parent
4e43c88fca
commit
6e7601e3d4
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue