lasthourcloud/app/Http/Livewire/Project/DeleteEnvironment.php
Andras Bacsai a378b5108e refactor a lot of things
fix: postgres_passwords could be longer
feat: able to define postgresql databases from the ui
2023-08-09 15:57:53 +02:00

31 lines
805 B
PHP

<?php
namespace App\Http\Livewire\Project;
use App\Models\Environment;
use Livewire\Component;
class DeleteEnvironment extends Component
{
public array $parameters;
public int $environment_id;
public function mount()
{
$this->parameters = get_route_parameters();
}
public function delete()
{
$this->validate([
'environment_id' => 'required|int',
]);
$environment = Environment::findOrFail($this->environment_id);
if ($environment->applications->count() > 0) {
return $this->emit('error', 'Environment has resources defined, please delete them first.');
}
$environment->delete();
return redirect()->route('project.show', ['project_uuid' => $this->parameters['project_uuid']]);
}
}