adrema/app/Member/DeleteJob.php

47 lines
985 B
PHP
Raw Normal View History

2021-06-24 00:12:47 +02:00
<?php
namespace App\Member;
2022-09-05 11:37:54 +02:00
use App\Setting\NamiSettings;
2021-06-24 00:12:47 +02:00
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class DeleteJob implements ShouldQueue
{
2022-03-11 20:19:17 +01:00
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
2021-06-24 00:12:47 +02:00
2022-02-12 15:35:58 +01:00
public int $memberId;
public Member $member;
2021-06-24 00:12:47 +02:00
2022-02-19 18:06:07 +01:00
public function __construct(Member $member)
2021-06-24 00:12:47 +02:00
{
$this->memberId = $member->id;
}
/**
* Execute the job.
*
* @return void
*/
2022-09-05 11:37:54 +02:00
public function handle(NamiSettings $setting)
2021-06-24 00:12:47 +02:00
{
$this->member = Member::find($this->memberId);
if (!$this->member->hasNami) {
2022-01-02 12:32:57 +01:00
return;
2021-06-24 00:12:47 +02:00
}
2022-02-19 18:06:07 +01:00
$setting->login()->deleteMember($this->member->nami_id);
2021-06-24 00:12:47 +02:00
2022-03-11 20:19:17 +01:00
Member::withoutEvents(function () {
2021-06-24 00:12:47 +02:00
$this->member->update(['nami_id' => null]);
});
}
}