FilamentF
Filament16mo ago
Patie

Records count in table header

Hi, its possible to have current records count (init, but also after filtering or searching) in table header? I tried multiple ways, but without luck yet.
Solution
looks like its working with:

    public function updated()
    {
        $this->total = $this->getFilteredTableQuery()->count();
        $this->getTable()->header($this->getTableHeader());
    }

    public function rendering()
    {
        $this->total = $this->getFilteredTableQuery()->count();
        $this->getTable()->header($this->getTableHeader());
    }

    protected function getTableHeader(): ?View
    {
        if ($this->total > 0) {
            return view('components.banner', ['message' => $this->total, 'style' => 'warning']);
        }
        return null;
    }


its correct way how to do it?
Was this page helpful?