rappasoft / laravel-livewire-tables

A dynamic table component for Laravel Livewire
https://rappasoft.com/docs/laravel-livewire-tables/v2/introduction
MIT License
1.78k stars 338 forks source link

[Bug]: Filter refresh #1958

Closed OndrejMiko closed 1 month ago

OndrejMiko commented 1 month ago

What happened?

Hello , i got problem with filter if I dynamicaly change values for filter field in livewire code . In version 2 its working but in version 3 filter not refresh values from livewire in function filters() Any suggestion please , thank you

How to reproduce the bug

No response

Package Version

3.4

PHP Version

8.3.x

Laravel Version

10.10

Alpine Version

3.13

Theme

Tailwind 3.x

Notes

No response

Error Message

No response

lrljoe commented 1 month ago

Please share an example of exactly what you're doing

OndrejMiko commented 1 month ago

Hello In function

public function filters(): array{
       $payment_types=$this->filterPaymentTypes;

        $filters=array();

        $filters["payment_state"]=SelectFilter::make(__("payment_state"),"payment_state")
            ->options($payment_states)
            ->filter(function(Builder $query, $value) {
                $query->where('payment_state', '=', $value);
            });
}

If I change in livewire $filterPaymentTypes by changing other filter values , filter dont change select , in v2 it works use like this . I need to change second select filter depends on first select filter value , like u pick car brand in first and second filter change models .

Thank you

lrljoe commented 1 month ago
public function filters()

Needs to RETURN an array.

lrljoe commented 1 month ago

In your example - Do you want "car brand" to apply any logic to the query? Or only "car models" to apply logic to the query?

OndrejMiko commented 1 month ago

In your example - Do you want "car brand" to apply any logic to the query? Or only "car models" to apply logic to the query?

I know it must have return array, i dont write it there it was just example.

I just need conditional logic in filter . If I set in first filter field "car brand" it must change second filter field "car models" to this brand only models . The second filter field "car models" should only show models to selected first filter field "car brand"

Its it clear or should I create image example ?

Thank you