fix: add error message + instruction to detach team from vacancy

Fixes #10.

Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
Miguel Nogueira 2022-10-22 00:34:54 +01:00
parent 73a674096a
commit dced0907b6
No known key found for this signature in database
GPG Key ID: 3C6A7E29AF26D370

View File

@ -153,10 +153,18 @@ class VacancyController extends Controller
public function delete(Request $request, Vacancy $vacancy) public function delete(Request $request, Vacancy $vacancy)
{ {
$this->authorize('delete', $vacancy); $this->authorize('delete', $vacancy);
$vacancy->delete();
if ($vacancy->teams->isEmpty()) {
$vacancy->delete();
return redirect()
->back()
->with('success', __('Vacancy deleted. All applications associated with it are now gone too.'));
}
return redirect() return redirect()
->back() ->back()
->with('success', __('Vacancy deleted. All applications associated with it are now gone too.')); ->with('error', __('Please detach any teams that may be using this vacancy first.'));
} }
} }