Arcanedev\LogViewer\Tables\StatsTable::totals PHP Method

totals() public method

Get totals.
public totals ( string | null $locale = null ) : Collection
$locale string | null
return Illuminate\Support\Collection
    public function totals($locale = null)
    {
        $this->setLocale($locale);
        $totals = Collection::make();
        foreach (Arr::except($this->footer(), 'all') as $level => $count) {
            $totals->put($level, ['label' => $this->translate("levels.{$level}"), 'value' => $count, 'color' => $this->color($level), 'highlight' => $this->color($level)]);
        }
        return $totals;
    }

Usage Example

 /**
  * Prepare chart data.
  *
  * @param  \Arcanedev\LogViewer\Tables\StatsTable  $stats
  *
  * @return string
  */
 protected function prepareChartData(StatsTable $stats)
 {
     $totals = $stats->totals()->all();
     return json_encode(['labels' => Arr::pluck($totals, 'label'), 'datasets' => [['data' => Arr::pluck($totals, 'value'), 'backgroundColor' => Arr::pluck($totals, 'color'), 'hoverBackgroundColor' => Arr::pluck($totals, 'highlight')]]]);
 }