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->withColumns([
$this->fromTable()
->except(['index'])
->withColumns([
Column::make('title')
->heading('Judul'),

View File

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

View File

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

View File

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

View File

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

View File

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