validate([ 'project_id' => 'required|int', ]); $project = Project::findOrFail($this->project_id); if ($project->applications->count() > 0) { return $this->emit('error', 'Project has applications, please delete them first.'); } $project->delete(); return redirect()->route('dashboard'); } }