save filter data in variable

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',
];
}

protected function getFilters(): ?array
{
return [
null => 'Show All',
0 => 'In Progress',
1 => 'Order',
2 => 'Completed',
3 => 'Cancelled',
];
}
if i choose in Progress i want to save 0 in $status
10 Replies
toeknee
toeknee2mo ago
Can you explain your goal more?
gigiloouu
gigiloouu2mo ago
i have purchases table
$query = Purchase::where('supplier_id', $this->supplierId)
$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);
}
if ($this->status !== null) { // Handle filtering by status
$query->where('status', $this->filters);
}
public ?int $status = null; // Change to int to match status values
public ?int $status = null; // Change to int to match status values
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',
];
}
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?
toeknee
toeknee2mo ago
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.
gigiloouu
gigiloouu2mo ago
look i have chart widget
gigiloouu
gigiloouu2mo ago
No description
gigiloouu
gigiloouu2mo ago
which have filter in right side
protected function getFilters(): ?array
{
return [
null => 'Show All',
0 => 'In Progress',
1 => 'Order',
2 => 'Completed',
3 => 'Cancelled',
];
}
protected function getFilters(): ?array
{
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
gigiloouu
gigiloouu2mo ago
?? anyone please?
toeknee
toeknee2mo ago
So you want to filter the resource data from the widget filter form? Is that correct?
gigiloouu
gigiloouu2mo ago
yes i have filter for my widget anyone can helpme?
Want results from more Discord servers?
Add your server