2023-11-06 11:31:02 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Server;
|
2023-11-06 11:31:02 +00:00
|
|
|
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Delete extends Component
|
|
|
|
{
|
|
|
|
use AuthorizesRequests;
|
|
|
|
|
|
|
|
public $server;
|
|
|
|
public function delete()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->authorize('delete', $this->server);
|
2023-11-06 17:04:18 +00:00
|
|
|
if ($this->server->hasDefinedResources()) {
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('error', 'Server has defined resources. Please delete them first.');
|
2023-11-06 11:31:02 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$this->server->delete();
|
2024-01-07 15:23:41 +00:00
|
|
|
return redirect()->route('server.index');
|
2023-11-06 11:31:02 +00:00
|
|
|
} catch (\Throwable $e) {
|
|
|
|
return handleError($e, $this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.server.delete');
|
|
|
|
}
|
|
|
|
}
|