Table widget custom filter does not update table result
I've been asked by my client to have an overview table with the most popular coupons on our site through a list with filters.
Therefore i proceeded to create the following table widget
Therefore i proceeded to create the following table widget
class MostVisitedCouponsTableWidget extends BaseWidget
{
public function getColumnSpan(): int|string|array
{
return ['default' => 'full'];
}
public function table(Table $table): Table
{
return $table
->paginated(false)
->query(
Coupon::query()
->select(["id", "title", "store_id", "status"])
->scopes(['published'])
->withCount([
'impressions'
])
->having('impressions_count', '>', 0)
->orderByDesc('impressions_count')
->limit(10)
)
->columns([
TextColumn::make('id'),
TextColumn::make('title'),
TextColumn::make('store.business_name'),
TextColumn::make('impressions_count')->badge(),
]);
}
}class MostVisitedCouponsTableWidget extends BaseWidget
{
public function getColumnSpan(): int|string|array
{
return ['default' => 'full'];
}
public function table(Table $table): Table
{
return $table
->paginated(false)
->query(
Coupon::query()
->select(["id", "title", "store_id", "status"])
->scopes(['published'])
->withCount([
'impressions'
])
->having('impressions_count', '>', 0)
->orderByDesc('impressions_count')
->limit(10)
)
->columns([
TextColumn::make('id'),
TextColumn::make('title'),
TextColumn::make('store.business_name'),
TextColumn::make('impressions_count')->badge(),
]);
}
}