mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Added destroy method to dept
This commit is contained in:
parent
a7592de304
commit
eb3aa99e4f
|
@ -81,4 +81,30 @@ class DepartmentsController extends Controller
|
||||||
$department = Department::findOrFail($id);
|
$department = Department::findOrFail($id);
|
||||||
return (new DepartmentsTransformer)->transformDepartment($department);
|
return (new DepartmentsTransformer)->transformDepartment($department);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates and deletes selected location.
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @param int $locationId
|
||||||
|
* @since [v1.0]
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
if (is_null($department = Department::find($id))) {
|
||||||
|
return redirect()->to(route('departments.index'))->with('error', trans('admin/departments/message.not_found'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($department->users->count() > 0) {
|
||||||
|
return redirect()->to(route('departments.index'))->with('error', trans('admin/departments/message.assoc_users'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$department->delete();
|
||||||
|
return redirect()->to(route('departments.index'))->with('success', trans('admin/departments/message.delete.success'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue