adrema/app/Member/DeleteJob.php

48 lines
1.1 KiB
PHP
Raw Normal View History

2021-06-24 00:12:47 +02:00
<?php
namespace App\Member;
2022-01-02 12:32:57 +01:00
use App\Confession;
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;
use Zoomyboy\LaravelNami\Nami;
2022-02-12 15:35:58 +01:00
use Zoomyboy\LaravelNami\NamiUser;
2021-06-24 00:12:47 +02:00
class DeleteJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
2022-02-12 15:35:58 +01:00
public int $memberId;
public Member $member;
public NamiUser $user;
2021-06-24 00:12:47 +02:00
2022-02-12 15:35:58 +01:00
public function __construct(Member $member, NamiUser $user)
2021-06-24 00:12:47 +02:00
{
$this->memberId = $member->id;
$this->user = $user;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$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
}
Nami::login($this->user->mglnr)->deleteMember($this->member->nami_id);
Member::withoutEvents(function() {
$this->member->update(['nami_id' => null]);
});
}
}