Aplikasi Keuangan yang mengatur lalu lintas transaksi antara bank dan aplikasi internal Kampus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

24 lines
633 B

<?php
namespace App\Domains\Identity\Actions\Governance;
use App\Domains\Identity\Enums\RoleType;
use App\Domains\Identity\Events\Governance\UserWasPurged;
use App\Domains\Identity\Models\User;
use Exception;
class PurgeUser
{
/**
* @throws Exception
*/
public function execute(User $user): void
{
if ($user->hasRole([RoleType::SYSTEM_ADMIN, RoleType::ADMIN])) {
throw new Exception(__('domains/identity/messages.exceptions.user_cannot_be_purged'));
}
$user->delete();
UserWasPurged::dispatch(email: $user->email, user_id: $user->id, model: User::class);
}
}