F
Filament11mo ago
Gush

Select All option in relationship Select

Hey, i have a Select with relationship users, works fine but i would like a option to select all users at one
Select::make('user_id')
->multiple()
->native(false)
->searchable()
->preload()
->label(__('nlmn-event-module::scheduling.scheduling_resource.event_participants'))
->relationship('users', 'name'),
Select::make('user_id')
->multiple()
->native(false)
->searchable()
->preload()
->label(__('nlmn-event-module::scheduling.scheduling_resource.event_participants'))
->relationship('users', 'name'),
4 Replies
LeandroFerreira
LeandroFerreira11mo ago
->hintAction(fn (Select $component) => \Filament\Forms\Components\Actions\Action::make('select_all')
->action(fn () => $component->state(User::pluck('id')->toArray()))
)
->hintAction(fn (Select $component) => \Filament\Forms\Components\Actions\Action::make('select_all')
->action(fn () => $component->state(User::pluck('id')->toArray()))
)
hashim199
hashim1997mo ago
@Leandro Ferreira i have a bill table and a service table now the bill and services have a many to many relationship. On one bill one service can be taken multiple times like remove of tooth . but when i select one service from the list it disappears and i cant select it multiple times , so i want that i should be able to select one service multiple times
//service model public function bills() : BelongsToMany { return $this->belongsToMany(Bill::class, 'bill_service') ->withTimestamps(); } //Bill Model public function services() : BelongsToMany { return $this->belongsToMany(Service::class, 'bill_service') ->withTimestamps(); } //Bill Resource Forms\Components\Select::make('service_code') ->relationship('services','code') ->multiple() ->reactive() ->preload() ->live() ->required(), @Tin @toeknee
toeknee
toeknee7mo ago
Please read the rules @hashim199 tagging is not permitted.
hashim199
hashim1997mo ago
I really apologize

Did you find this page helpful?