2023-08-15 23:03:51 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Member\Actions;
|
|
|
|
|
2023-08-16 00:43:28 +02:00
|
|
|
use App\Lib\JobMiddleware\WithJobState;
|
2023-08-15 23:03:51 +02:00
|
|
|
use App\Maildispatcher\Actions\ResyncAction;
|
|
|
|
use App\Member\Member;
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
|
|
|
|
|
|
class MemberDeleteAction
|
|
|
|
{
|
|
|
|
|
|
|
|
use AsAction;
|
|
|
|
|
2023-08-16 00:43:28 +02:00
|
|
|
public function handle(int $memberId): void
|
2023-08-15 23:03:51 +02:00
|
|
|
{
|
2023-08-16 00:43:28 +02:00
|
|
|
$member = Member::findOrFail($memberId);
|
|
|
|
|
2023-08-15 23:03:51 +02:00
|
|
|
if ($member->nami_id) {
|
2023-08-16 00:43:28 +02:00
|
|
|
NamiDeleteMemberAction::run($member->nami_id);
|
2023-08-15 23:03:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$member->delete();
|
2023-08-16 00:43:28 +02:00
|
|
|
ResyncAction::run();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function asController(Member $member): RedirectResponse
|
|
|
|
{
|
|
|
|
static::dispatch($member->id);
|
2023-08-15 23:03:51 +02:00
|
|
|
|
|
|
|
return redirect()->back();
|
|
|
|
}
|
2023-08-16 00:43:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array<int, object>
|
|
|
|
*/
|
|
|
|
public function getJobMiddleware(int $memberId): array
|
|
|
|
{
|
|
|
|
$member = Member::findOrFail($memberId);
|
|
|
|
|
|
|
|
return [
|
|
|
|
WithJobState::make('member')
|
|
|
|
->before('Lösche Mitglied ' . $member->fullname)
|
|
|
|
->after('Mitglied ' . $member->fullname . ' gelöscht')
|
|
|
|
->shouldReload(),
|
|
|
|
];
|
|
|
|
}
|
2023-08-15 23:03:51 +02:00
|
|
|
}
|