© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
hello_world

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;
                    }),
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();
                    })
 ->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
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Select multiple issue
FilamentFFilament / ❓┊help
3y ago
Issue with the select multiple state
FilamentFFilament / ❓┊help
13mo ago
Multiple Select Many to Many Disabled issue
FilamentFFilament / ❓┊help
13mo ago
Select component Allow Multiple select
FilamentFFilament / ❓┊help
2y ago