reportService = $reportService; $this->exportService = $exportService; } /** * @return array */ public function getTable(): array { return [ Column::make('date') ->label('Date') ->alignment(Alignment::Left), Column::make('description') ->label('Description') ->alignment(Alignment::Left), Column::make('debit') ->label('Debit') ->alignment(Alignment::Right), Column::make('credit') ->label('Credit') ->alignment(Alignment::Right), Column::make('balance') ->label('Balance') ->alignment(Alignment::Right), ]; } public function form(Form $form): Form { return $form ->columns(4) ->live() ->schema([ Select::make('account_id') ->label('Account') ->options($this->getAccountOptions()) ->selectablePlaceholder(false) ->searchable(), $this->getDateRangeFormComponent(), Cluster::make([ $this->getStartDateFormComponent(), $this->getEndDateFormComponent(), ])->label("\u{200B}"), // its too bad hiddenLabel removes spacing of the label Actions::make([ Actions\Action::make('loadReportData') ->label('Update Report') ->submit('loadReportData') ->keyBindings(['mod+s']), ])->alignEnd()->verticallyAlignEnd(), ]); } protected function getAccountOptions(): array { $accounts = Account::query() ->get() ->groupBy(fn (Account $account) => $account->category->getPluralLabel()) ->map(fn (Collection $accounts, string $category) => $accounts->pluck('name', 'id')) ->toArray(); $allAccountsOption = [ 'All Accounts' => ['all' => 'All Accounts'], ]; return $allAccountsOption + $accounts; } protected function buildReport(array $columns): ReportDTO { return $this->reportService->buildAccountTransactionsReport($this->startDate, $this->endDate, $columns, $this->account_id); } protected function getTransformer(ReportDTO $reportDTO): ExportableReport { return new AccountTransactionReportTransformer($reportDTO); } public function exportCSV(): StreamedResponse { return $this->exportService->exportToCsv($this->company, $this->report, $this->startDate, $this->endDate); } public function exportPDF(): StreamedResponse { return $this->exportService->exportToPdf($this->company, $this->report, $this->startDate, $this->endDate); } public function getEmptyStateHeading(): string | Htmlable { return 'No Transactions Found'; } public function getEmptyStateDescription(): string | Htmlable | null { return 'Adjust the account or date range, or start by creating a transaction.'; } public function getEmptyStateIcon(): string { return 'heroicon-o-x-mark'; } public function getEmptyStateActions(): array { return [ Action::make('createTransaction') ->label('Create Transaction') ->url(Transactions::getUrl()), ]; } public function tableHasEmptyState(): bool { if ($this->report) { return empty($this->report->getCategories()); } else { return true; } } }