3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-03-30 04:14:17 +00:00

Merge pull request #12599 from inietov/fixes/unknown_column_0_in_field_list

Fixed Column not found: 1054 Unknown column '0' in 'field list' [sc-20004]
This commit is contained in:
snipe
2023-03-14 09:51:42 -07:00
committed by GitHub

View File

@ -20,6 +20,7 @@ use Auth;
use Illuminate\Http\Request;
use App\Http\Requests\ImageUploadRequest;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Validator;
class UsersController extends Controller
{
@ -457,6 +458,13 @@ class UsersController extends Controller
// Check if the request has groups passed and has a value
if ($request->filled('groups')) {
$validator = Validator::make($request->all(), [
'groups.*' => 'integer|exists:permission_groups,id',
]);
if ($validator->fails()){
return response()->json(Helper::formatStandardApiResponse('error', null, $user->getErrors()));
}
$user->groups()->sync($request->input('groups'));
// The groups field has been passed but it is null, so we should blank it out
} elseif ($request->has('groups')) {