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(3) ->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 ]); } 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); } }