vito/app/Actions/Server/DeleteServer.php
Saeed Vaziry 5c72f12490 init
2023-07-02 12:47:50 +02:00

34 lines
723 B
PHP
Executable File

<?php
namespace App\Actions\Server;
use App\Models\Server;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
class DeleteServer
{
/**
* @throws ValidationException
*/
public function delete(Server $server, array $input): void
{
$this->validateDelete($input);
DB::transaction(function () use ($server) {
$server->cleanDelete();
});
}
/**
* @throws ValidationException
*/
protected function validateDelete(array $input): void
{
Validator::make($input, [
'confirm' => 'required|in:delete',
])->validateWithBag('deleteServer');
}
}