lasthourcloud/app/Http/Livewire/Project/DeleteProject.php
Andras Bacsai f79b3841c7 fixes
2023-06-15 09:15:41 +02:00

31 lines
739 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 int $resource_count = 0;
public function mount()
{
$this->parameters = getRouteParameters();
}
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');
}
}