mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Fixes #3860 - return JSON instead of redirect in API delete dept call
This commit is contained in:
parent
8c5312b931
commit
eaaea303f4
|
@ -99,16 +99,14 @@ class DepartmentsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
if (is_null($department = Department::find($id))) {
|
$department = Department::findOrFail($id);
|
||||||
return redirect()->to(route('departments.index'))->with('error', trans('admin/departments/message.not_found'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($department->users->count() > 0) {
|
if ($department->users->count() > 0) {
|
||||||
return redirect()->to(route('departments.index'))->with('error', trans('admin/departments/message.assoc_users'));
|
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/departments/message.assoc_users')));
|
||||||
}
|
}
|
||||||
|
|
||||||
$department->delete();
|
$department->delete();
|
||||||
return redirect()->to(route('departments.index'))->with('success', trans('admin/departments/message.delete.success'));
|
return response()->json(Helper::formatStandardApiResponse('success', null, trans('admin/departments/message.delete.success')));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue