lasthourcloud/app/Http/Livewire/Project/DeleteProject.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
706 B
PHP

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