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:
commit
dfd9fcc5e0
1 changed files with 8 additions and 0 deletions
|
@ -20,6 +20,7 @@ use Auth;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Requests\ImageUploadRequest;
|
use App\Http\Requests\ImageUploadRequest;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
class UsersController extends Controller
|
class UsersController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -457,6 +458,13 @@ class UsersController extends Controller
|
||||||
|
|
||||||
// Check if the request has groups passed and has a value
|
// Check if the request has groups passed and has a value
|
||||||
if ($request->filled('groups')) {
|
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'));
|
$user->groups()->sync($request->input('groups'));
|
||||||
// The groups field has been passed but it is null, so we should blank it out
|
// The groups field has been passed but it is null, so we should blank it out
|
||||||
} elseif ($request->has('groups')) {
|
} elseif ($request->has('groups')) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue