mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
27 lines
622 B
PHP
27 lines
622 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Actions\Users;
|
|
|
|
use Pterodactyl\Contracts\Users\DeletesUsers;
|
|
use Pterodactyl\Exceptions\DisplayException;
|
|
use Pterodactyl\Models\User;
|
|
|
|
final class DeleteUser implements DeletesUsers
|
|
{
|
|
/**
|
|
* Delete a user from the panel only if they have no servers attached to their account.
|
|
*
|
|
* @throws DisplayException
|
|
*/
|
|
public function delete(User $user): ?bool
|
|
{
|
|
if ($user->servers()->exists()) {
|
|
throw new DisplayException(trans('admin/user.exceptions.user_has_servers'));
|
|
}
|
|
|
|
return $user->delete();
|
|
}
|
|
}
|