where('created_at', '>=', now()->subDays(30)) ->groupBy('date') ->orderBy('date') ->get(); $labels = $data->pluck('date')->map(fn ($date) => \Morilog\Jalali\Jalalian::fromCarbon(\Carbon\Carbon::parse($date))->format('Y/m/d'))->toArray(); $deposits = $data->pluck('deposits')->toArray(); $withdrawals = $data->pluck('withdrawals')->toArray(); return [ 'datasets' => [ [ 'label' => 'واریزی‌ها', 'data' => $deposits, 'borderColor' => '#10b981', 'backgroundColor' => 'rgba(16, 185, 129, 0.1)', 'fill' => true, 'tension' => 0.4, ], [ 'label' => 'برداشت‌ها', 'data' => $withdrawals, 'borderColor' => '#f59e0b', 'backgroundColor' => 'rgba(245, 158, 11, 0.1)', 'fill' => true, 'tension' => 0.4, ], ], 'labels' => $labels, ]; } protected function getType(): string { return 'line'; } protected function getOptions(): array { return [ 'plugins' => [ 'legend' => [ 'position' => 'top', 'labels' => [ 'font' => [ 'family' => 'inherit', ], ], ], ], 'scales' => [ 'y' => [ 'beginAtZero' => true, 'ticks' => [ 'callback' => 'function(value) { return value.toLocaleString("fa-IR"); }', ], ], 'x' => [ 'ticks' => [ 'maxRotation' => 0, ], ], ], ]; } }