Tab Badge not updating
I have a tab in ListBlogPosts where i have two tabs with badge that has count.
I want the count to be dyanamically updated based on my active filter. Sadly, the count does not update. Probably the code to generate the badge does not run on filter change. Is there a way to achieve it?
public function getTabs(): array
{
$filterYear = $this->getTableFilterState('publish_year')['value'];
$filterMonth = $this->getTableFilterState('publish_month')['value'];
return [
'all' => Tab::make(),
'waiting_for_assignees' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where(fn ($q) => $q->whereDoesntHave('website.blogAssigned')->orDoesntHave('website.seoSupportAssigned'))
)
->label('Waiting for Assignees')
->badge(fn () => BlogPost::where(fn ($q) => $q->whereDoesntHave('website.blogAssigned')->orDoesntHave('website.seoSupportAssigned'))
->whereYear('publish_date', $filterYear)
->whereMonth('publish_date', $filterMonth)
->count()),
'waiting_for_title' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->whereNull('title')
)
->label('Waiting for Title')
->badge(fn () => BlogPost::whereNull('title')
->whereYear('publish_date', $filterYear)
->whereMonth('publish_date', $filterMonth)
->count()
),
];
}
public function getTabs(): array
{
$filterYear = $this->getTableFilterState('publish_year')['value'];
$filterMonth = $this->getTableFilterState('publish_month')['value'];
return [
'all' => Tab::make(),
'waiting_for_assignees' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->where(fn ($q) => $q->whereDoesntHave('website.blogAssigned')->orDoesntHave('website.seoSupportAssigned'))
)
->label('Waiting for Assignees')
->badge(fn () => BlogPost::where(fn ($q) => $q->whereDoesntHave('website.blogAssigned')->orDoesntHave('website.seoSupportAssigned'))
->whereYear('publish_date', $filterYear)
->whereMonth('publish_date', $filterMonth)
->count()),
'waiting_for_title' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query
->whereNull('title')
)
->label('Waiting for Title')
->badge(fn () => BlogPost::whereNull('title')
->whereYear('publish_date', $filterYear)
->whereMonth('publish_date', $filterMonth)
->count()
),
];
}
0 Replies