-
app/Http/Livewire/Dashboard/Daily.php
Open in GitHubuse App\Models\Configuration; use App\Models\LogConfiguration; use Illuminate\Support\Facades\DB; use Livewire\Component; class Daily extends Component { public $daily; public function mount(): void { $date = DB::raw('DATE(`created_at`) as `date`'); if (config('database.default') === 'pgsql') { $date = DB::raw("date_trunc('day', created_at) as date"); } $this->daily = LogConfiguration::select(array( $date, DB::raw('count(*) as count') )) ->groupBy('date') ->orderBy('date', 'DESC') // or ASC ->pluck('count', 'date'); } // }
-
resources/views/livewire/dashboard/daily.blade.php
Open in GitHub// <tbody class="bg-white divide-y divide-gray-200"> @foreach($daily as $date => $count) <tr class=""> <x-table.td> {{ $date }} </x-table.td> <x-table.td align="right"> {{ $count }} </x-table.td> </tr> @endforeach </tbody> //