Power-Components / livewire-powergrid

⚡ PowerGrid generates modern, powerful and easy-to-customize data tables using Laravel Livewire.
https://livewire-powergrid.com
MIT License
1.48k stars 217 forks source link

Count uncountable variable in WithultiSelectBuilder trait #1614

Closed gyroid closed 2 months ago

gyroid commented 3 months ago

Have you searched through other issues to see if your problem is already reported or has been fixed?

Yes, I did not find it.

Did you read the documentation?

Yes, I did not find it.

Have you tried to publish the views?

No, this error is not related to views.

Is there an error in the console?

No

PHP Version

8.2

PowerGrid

5.9.0

Laravel

11.14.0

Livewire

3.5.2

Alpine JS

No response

Theme

Tailwind 3.x

Describe the bug.

Using dynamic filter with WireUI select for many-to-many relations I have the error:

"count(): Argument #1 ($value) must be of type Countable|array, null given"

when the filter is first time selected.

I fixed this bug changing the code.

In \PowerComponents\LivewirePowerGrid\Components\Filters\Builders\WithMultiSelectBuilder in line 25 instead of

if (count($values) === 0) { return; }

should be:

if (!is_countable($values) || count($values) === 0) { return; }

To Reproduce...

First click on "FOO" then....

Extra information

<?php
 //...