Adding where condition for filter in statsOverviewWidget

Tables\Filters\SelectFilter::make('category')
                    ->relationship('categories', 'name')
                    ->searchable()
                    ->preload()


use InteractsWithPageTable;

    protected function getTablePage(): string
    {
        return ListPosts::class;
    }

    protected function getStats(): array
    {
        return [
            BaseWidget\Stat::make('Published Post', $this->getPageTableQuery()
                ->with('categories')
                ->whereRelation('category', 'title', '', '')
                ->where('status', 'published')
                ->count())
                ->description('All published posts')
                ->color('success'),
Was this page helpful?