mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-05-07 20:32:26 +00:00
31 lines
706 B
PHP
31 lines
706 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Jetstream;
|
|
|
|
use App\Exceptions\Api\ApiException;
|
|
use App\Models\User;
|
|
use App\Service\DeletionService;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Laravel\Jetstream\Contracts\DeletesUsers;
|
|
|
|
class DeleteUser implements DeletesUsers
|
|
{
|
|
/**
|
|
* Delete the given user.
|
|
*
|
|
* @throws ValidationException
|
|
*/
|
|
public function delete(User $user): void
|
|
{
|
|
try {
|
|
app(DeletionService::class)->deleteUser($user);
|
|
} catch (ApiException $exception) {
|
|
throw ValidationException::withMessages([
|
|
'password' => $exception->getTranslatedMessage(),
|
|
]);
|
|
}
|
|
}
|
|
}
|