up
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use App\Models\Venta;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class VentasChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $heading = 'Reporte de Ventas';
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$ventas = Venta::whereBetween('created_at', [Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth()])
|
||||
->groupByRaw('DATE(created_at)')
|
||||
->selectRaw('DATE(created_at) as dia, SUM(total) as total')
|
||||
->pluck('total', 'dia');
|
||||
|
||||
|
||||
return [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => 'Ventas del mes',
|
||||
'data' => array_values($ventas->toArray()),
|
||||
],
|
||||
],
|
||||
'labels' => array_keys($ventas->toArray()),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'bar';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user