countByStatus(); $openComplaints = app(InsForgeClient::class)->countRecords('complaints', [ 'status' => ComplaintService::STATUS_OPEN, ]); $critical = collect(app(StockService::class)->paginate(perPage: 100)->items()) ->filter(fn (array $row): bool => (int) $row['quantity'] <= (int) data_get($row, 'products.stock_minimum', 0)) ->count(); return [ Stat::make('Pending', (string) ($counts[OrderService::STATUS_PENDING] ?? 0))->color('gray'), Stat::make('Diproses', (string) ($counts[OrderService::STATUS_PROCESSING] ?? 0))->color('info'), Stat::make('Dikirim', (string) ($counts[OrderService::STATUS_DELIVERING] ?? 0))->color('warning'), Stat::make('Selesai', (string) ($counts[OrderService::STATUS_COMPLETED] ?? 0))->color('success'), Stat::make('Komplain Terbuka', (string) $openComplaints)->color($openComplaints > 0 ? 'danger' : 'success'), Stat::make('Stok Kritis', (string) $critical)->color($critical > 0 ? 'danger' : 'success'), ]; } }