#save filter data in variable

23 messages · Page 1 of 1 (latest)

valid sable
#

in my code i want to save choosen filter in my variable like i have $status variable and i want to save there this ```
protected function getFilters(): ?array
{
return [
null => 'Show All',
0 => 'In Progress',
1 => 'Order',
2 => 'Completed',
3 => 'Cancelled',
];
}

gilded spruceBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

outer pine
#

Can you explain your goal more?

valid sable
#

i have purchases table ``` $query = Purchase::where('supplier_id', $this->supplierId)

#

and im taiiking data like this next

#

i take data frm purchase using status if ($this->status !== null) { // Handle filtering by status $query->where('status', $this->filters); }

#
``` i have status variable like this
#

i want to use it to get puurchases items where stattus == my status variable

#

i create filter in my widget like this ``` protected function getFilters(): ?array
{
return [
null => 'Show All',
0 => 'In Progress',
1 => 'Order',
2 => 'Completed',
3 => 'Cancelled',
];
}

#

and i want when i select in progress save 0 in status variable and use it to take purchases items where status === 0

#

u get it?

outer pine
#

If you have created a filter it will filter the table by the selected value.... But where are you wanting to save it? I am not understanding.

valid sable
#

look i have chart widget

#

which have filter in right side

#
    {
        return [
            null => 'Show All', 
            0 => 'In Progress',
            1 => 'Order',
            2 => 'Completed',
            3 => 'Cancelled',
        ];
    }```
#

this filter

#

and i want like if i select In progress i want to take data from purchases where status == selected status

valid sable
#

??

valid sable
#

anyone please?

outer pine
#

So you want to filter the resource data from the widget filter form? Is that correct?

valid sable
#

yes i have filter for my widget