Multiple Select Issue

Select::make('pos_devices_id')
                    ->label('POS Devices')
                    ->default(function () {
                        $userId = auth()->user()->id;
                        return PosDevice::whereHas('users', function ($query) use ($userId) {
                            $query->where('users.id', $userId);
                        })->pluck('name','id')->toArray();
                    })
                    ->options(function (Get $get, Set $set) {
                        $userId = $get('user_id');

                        $test = PosDevice::doesntHave('users', 'and', function ($query) use ($userId) {
                            $query->where('user_id', $userId);
                        })->where('status', 1)->pluck('name', 'id')->toArray();
                        // $set('data', $test);
                        if ($userId) {
                            return $test;
                        }
                        return [];
                    })
                    ->multiple()
                    ->live()
                    ->afterStateUpdated(function (Get $get, $state) {
                        $assignDevices = $get('Assigned Devices');
                        info($state);
                        return $state;
                    }),

the saved data is not rendering properly if i use
 ->default(function () {
                        $userId = auth()->user()->id;
                        return PosDevice::whereHas('users', function ($query) use ($userId) {
                            $query->where('users.id', $userId);
                        })->pluck('id')->toArray();
                    })

then it is showing id's and if i use name in pluck then i am unable to sav it giving a error that string can't insert which type is bigInt
Was this page helpful?