-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
Package
filament/filament
Package Version
v4
Laravel Version
v12
Livewire Version
No response
PHP Version
PHP 8.4
Problem description
The goal
Update the managers
and assignees
relationships on the Ticket
model
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
public function managers(): BelongsToMany
{
return $this->users()
->wherePivot('user_role', TicketUserRole::Manager->value);
}
public function assignees(): BelongsToMany
{
return $this->users()
->wherePivot('user_role', TicketUserRole::Assignee->value);
}
using the ModalTableSelect
field.
While this works
Using a standard Select
field works perfectly fine.
Select::make('assignees')
->label(__('Verantwortung'))
->relationship()
->multiple()
->searchable([
'first_name',
'last_name',
])
->preload()
->pivotData([
'user_role' => TicketUserRole::Assignee,
])
->getOptionLabelFromRecordUsing(fn (User $record) => $record->getFilamentName()),
The correct users are selected by default and updating them works as expected.
This doesn't work
Using the ModalTableSelect
field results in an error on trying to open the modal.
ModalTableSelect::make('assignees')
->label(__('Verantwortung'))
->relationship()
->multiple()
->pivotData([
'user_role' => TicketUserRole::Assignee,
])
->tableConfiguration(UsersSelectTable::class)
->getOptionLabelFromRecordUsing(fn(User $record) => $record->getFilamentName()),
The correct users are selected by default but the following error appears on trying to open the modal SQLSTATE[HY093]: Invalid parameter number (Connection: mysql, SQL: select count(*) as aggregate from 'users')
I guess its about the wherePivot
calls. With the users
relationship everything works perfectly. But that's not what we want to achieve.
Expected behavior
Not to get the SQLSTATE[HY093]: Invalid parameter number (Connection: mysql, SQL: select count(*) as aggregate from 'users')
error.
Steps to reproduce
- Setup basic Laravel 12 / Filamentphp 4 environment
- Try updating an many-to-many relationship with an
wherePivot
call using theModalTableSelect
field.
Reproduction repository (issue will be closed if this is not valid)
https://github.com/AngeloKreienbuehl/filament-issue
Relevant log output
Metadata
Metadata
Assignees
Labels
Type
Projects
Status