Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

danielveselinov's avatar

HELP: Nested arrays may not be passed to whereIn method

I have this error in my Livewire componenet (Nested arrays may not be passed to whereIn method) whenever I try to retrieve the interests.

class UpdateForm extends Component implements HasForms
{
    use InteractsWithForms;

    public Event $event;
    public ?array $state = [];

    public function mount(Event $event): void
    {
        $this->event = $event;

        //$this->event->interests->pluck('id')->toArray();
        $this->form->fill($event->toArray());
    }

public function form(Form $form): Form
    {
        return $form
            ->schema([
Select::make('interests')
                                ->relationship('interests', 'name', modifyQueryUsing: fn(Builder $query) => $query->inRandomOrder())
                                ->searchable()
                                ->preload()
                                ->multiple()
                                ->required()
                                ->rules(['required', 'array', 'min:6', 'max:30']),])->statePath('state')->model($this->event);
}

In my EventResource it works fine, but in my livewire component, it doesn't. The relation is belongsToMany(), table is event_interest

0 likes
2 replies
kevinbui's avatar

Can you share the full error stack trace?

Sibi's avatar

I had the same issue, turns out ->relation does not like it when you eager load the relationship in your model. I had my relationship inside the $with array on the model. When I removed this the selection field worked again.

1 like

Please or to participate in this conversation.