mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Adds try/catch to users API
This commit is contained in:
parent
78b36c7886
commit
e0b2dc043a
|
@ -452,10 +452,18 @@ class UsersController extends Controller
|
|||
|
||||
// Check if the request has groups passed and has a value
|
||||
if ($request->filled('groups')) {
|
||||
try{
|
||||
$user->groups()->sync($request->input('groups'));
|
||||
} catch (\Exception $exception){
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $exception));
|
||||
}
|
||||
// The groups field has been passed but it is null, so we should blank it out
|
||||
} elseif ($request->has('groups')) {
|
||||
try{
|
||||
$user->groups()->sync([]);
|
||||
} catch (\Exception $exception){
|
||||
return response()->json(Helper::formatStandardApiResponse('error', null, $exception));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue