refactor: Update Excel export setup in Filament resources to use fromTable() method for improved consistency and maintainability

This commit is contained in:
Yoga Pangestu 2026-04-06 10:19:20 +07:00
parent 4f465b17bb
commit 75bd1ad3e6
6 changed files with 78 additions and 76 deletions

View File

@ -16,7 +16,9 @@ public function setUp()
{ {
$this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d')); $this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d'));
$this->withColumns([ $this->fromTable()
->except(['index'])
->withColumns([
Column::make('title') Column::make('title')
->heading('Judul'), ->heading('Judul'),

View File

@ -16,7 +16,9 @@ public function setUp()
{ {
$this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d')); $this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d'));
$this->withColumns([ $this->fromTable()
->except(['index'])
->withColumns([
Column::make('mediaMonitoring.title') Column::make('mediaMonitoring.title')
->heading('Judul Berita'), ->heading('Judul Berita'),

View File

@ -2,7 +2,6 @@
namespace App\Filament\Exports; namespace App\Filament\Exports;
use App\Enums\Channel;
use Maatwebsite\Excel\Concerns\WithEvents; use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithStyles; use Maatwebsite\Excel\Concerns\WithStyles;
use Maatwebsite\Excel\Events\AfterSheet; use Maatwebsite\Excel\Events\AfterSheet;
@ -17,7 +16,9 @@ public function setUp()
{ {
$this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d')); $this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d'));
$this->withColumns([ $this->fromTable()
->except(['index'])
->withColumns([
Column::make('code') Column::make('code')
->heading('Kode'), ->heading('Kode'),
@ -29,7 +30,7 @@ public function setUp()
Column::make('channel') Column::make('channel')
->heading('Kanal') ->heading('Kanal')
->formatStateUsing(fn ($state) => Channel::tryFrom($state)?->getLabel() ?? $state), ->formatStateUsing(fn ($state) => $state->getLabel() ?? $state),
Column::make('writter') Column::make('writter')
->heading('Penulis'), ->heading('Penulis'),

View File

@ -22,8 +22,7 @@ protected function getHeaderActions(): array
ExportAction::make() ExportAction::make()
->exports([ ->exports([
ContentRecapExcelExport::make() ContentRecapExcelExport::make(),
->fromTable(),
]) ])
->color('success') ->color('success')
->icon(null), ->icon(null),

View File

@ -22,8 +22,7 @@ protected function getHeaderActions(): array
ExportAction::make() ExportAction::make()
->exports([ ->exports([
IssueManagementExcelExport::make() IssueManagementExcelExport::make(),
->fromTable(),
]) ])
->color('success') ->color('success')
->icon(null), ->icon(null),

View File

@ -25,8 +25,7 @@ protected function getHeaderActions(): array
ExportAction::make() ExportAction::make()
->exports([ ->exports([
MediaMonitoringExcelExport::make() MediaMonitoringExcelExport::make(),
->fromTable(),
]) ])
->color('success') ->color('success')
->icon(null), ->icon(null),