refactor: Update Excel export setup in Filament resources to use fromTable() method for improved consistency and maintainability
This commit is contained in:
parent
4f465b17bb
commit
75bd1ad3e6
@ -16,32 +16,34 @@ public function setUp()
|
||||
{
|
||||
$this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d'));
|
||||
|
||||
$this->withColumns([
|
||||
Column::make('title')
|
||||
->heading('Judul'),
|
||||
$this->fromTable()
|
||||
->except(['index'])
|
||||
->withColumns([
|
||||
Column::make('title')
|
||||
->heading('Judul'),
|
||||
|
||||
Column::make('type')
|
||||
->heading('Tipe')
|
||||
->formatStateUsing(fn ($state) => $state?->getLabel()),
|
||||
Column::make('type')
|
||||
->heading('Tipe')
|
||||
->formatStateUsing(fn ($state) => $state?->getLabel()),
|
||||
|
||||
Column::make('channel')
|
||||
->heading('Kanal')
|
||||
->formatStateUsing(fn ($state) => $state->getLabel()),
|
||||
Column::make('channel')
|
||||
->heading('Kanal')
|
||||
->formatStateUsing(fn ($state) => $state->getLabel()),
|
||||
|
||||
Column::make('social_media')
|
||||
->heading('Media Sosial')
|
||||
->formatStateUsing(fn ($state) => $state?->getLabel()),
|
||||
Column::make('social_media')
|
||||
->heading('Media Sosial')
|
||||
->formatStateUsing(fn ($state) => $state?->getLabel()),
|
||||
|
||||
Column::make('classification.name')
|
||||
->heading('Klasifikasi'),
|
||||
Column::make('classification.name')
|
||||
->heading('Klasifikasi'),
|
||||
|
||||
Column::make('link')
|
||||
->heading('Tautan'),
|
||||
Column::make('link')
|
||||
->heading('Tautan'),
|
||||
|
||||
Column::make('posting_date')
|
||||
->heading('Tgl Posting')
|
||||
->formatStateUsing(fn ($state) => $state?->translatedFormat('l, d F Y')),
|
||||
]);
|
||||
Column::make('posting_date')
|
||||
->heading('Tgl Posting')
|
||||
->formatStateUsing(fn ($state) => $state?->translatedFormat('l, d F Y')),
|
||||
]);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
|
||||
@ -16,37 +16,39 @@ public function setUp()
|
||||
{
|
||||
$this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d'));
|
||||
|
||||
$this->withColumns([
|
||||
Column::make('mediaMonitoring.title')
|
||||
->heading('Judul Berita'),
|
||||
$this->fromTable()
|
||||
->except(['index'])
|
||||
->withColumns([
|
||||
Column::make('mediaMonitoring.title')
|
||||
->heading('Judul Berita'),
|
||||
|
||||
Column::make('issue')
|
||||
->heading('Isu')
|
||||
->formatStateUsing(fn ($state) => $state?->getLabel()),
|
||||
Column::make('issue')
|
||||
->heading('Isu')
|
||||
->formatStateUsing(fn ($state) => $state?->getLabel()),
|
||||
|
||||
Column::make('response')
|
||||
->heading('Respon')
|
||||
->formatStateUsing(fn ($state) => $state?->getLabel()),
|
||||
Column::make('response')
|
||||
->heading('Respon')
|
||||
->formatStateUsing(fn ($state) => $state?->getLabel()),
|
||||
|
||||
Column::make('location.name')
|
||||
->heading('Lokus'),
|
||||
Column::make('location.name')
|
||||
->heading('Lokus'),
|
||||
|
||||
Column::make('subLocation.name')
|
||||
->heading('Sublokus'),
|
||||
Column::make('subLocation.name')
|
||||
->heading('Sublokus'),
|
||||
|
||||
Column::make('classification.name')
|
||||
->heading('Klasifikasi'),
|
||||
Column::make('classification.name')
|
||||
->heading('Klasifikasi'),
|
||||
|
||||
Column::make('subClassification.name')
|
||||
->heading('Subklasifikasi'),
|
||||
Column::make('subClassification.name')
|
||||
->heading('Subklasifikasi'),
|
||||
|
||||
Column::make('description')
|
||||
->heading('Keterangan'),
|
||||
Column::make('description')
|
||||
->heading('Keterangan'),
|
||||
|
||||
Column::make('mediaMonitoring.release_date')
|
||||
->heading('Tgl Rilis')
|
||||
->formatStateUsing(fn ($state) => $state?->translatedFormat('l, d F Y')),
|
||||
]);
|
||||
Column::make('mediaMonitoring.release_date')
|
||||
->heading('Tgl Rilis')
|
||||
->formatStateUsing(fn ($state) => $state?->translatedFormat('l, d F Y')),
|
||||
]);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
|
||||
@ -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,42 +16,44 @@ public function setUp()
|
||||
{
|
||||
$this->withFilename(fn ($resource) => $resource::getModelLabel().'-'.date('Y-m-d'));
|
||||
|
||||
$this->withColumns([
|
||||
Column::make('code')
|
||||
->heading('Kode'),
|
||||
$this->fromTable()
|
||||
->except(['index'])
|
||||
->withColumns([
|
||||
Column::make('code')
|
||||
->heading('Kode'),
|
||||
|
||||
Column::make('media_name')
|
||||
->heading('Nama Media'),
|
||||
Column::make('media_name')
|
||||
->heading('Nama Media'),
|
||||
|
||||
Column::make('title')
|
||||
->heading('Judul'),
|
||||
Column::make('title')
|
||||
->heading('Judul'),
|
||||
|
||||
Column::make('channel')
|
||||
->heading('Kanal')
|
||||
->formatStateUsing(fn ($state) => Channel::tryFrom($state)?->getLabel() ?? $state),
|
||||
Column::make('channel')
|
||||
->heading('Kanal')
|
||||
->formatStateUsing(fn ($state) => $state->getLabel() ?? $state),
|
||||
|
||||
Column::make('writter')
|
||||
->heading('Penulis'),
|
||||
Column::make('writter')
|
||||
->heading('Penulis'),
|
||||
|
||||
Column::make('link')
|
||||
->heading('Tautan'),
|
||||
Column::make('link')
|
||||
->heading('Tautan'),
|
||||
|
||||
Column::make('news_page')
|
||||
->heading('Halaman Berita'),
|
||||
Column::make('news_page')
|
||||
->heading('Halaman Berita'),
|
||||
|
||||
Column::make('influencer')
|
||||
->heading('Influencer'),
|
||||
Column::make('influencer')
|
||||
->heading('Influencer'),
|
||||
|
||||
Column::make('keyword')
|
||||
->heading('Kata Kunci'),
|
||||
Column::make('keyword')
|
||||
->heading('Kata Kunci'),
|
||||
|
||||
Column::make('themes')
|
||||
->heading('Tema')
|
||||
->getStateUsing(fn ($record) => $record->themes->pluck('name')->join(', ')),
|
||||
Column::make('themes')
|
||||
->heading('Tema')
|
||||
->getStateUsing(fn ($record) => $record->themes->pluck('name')->join(', ')),
|
||||
|
||||
Column::make('release_date')
|
||||
->heading('Tgl Rilis'),
|
||||
]);
|
||||
Column::make('release_date')
|
||||
->heading('Tgl Rilis'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
|
||||
@ -22,8 +22,7 @@ protected function getHeaderActions(): array
|
||||
|
||||
ExportAction::make()
|
||||
->exports([
|
||||
ContentRecapExcelExport::make()
|
||||
->fromTable(),
|
||||
ContentRecapExcelExport::make(),
|
||||
])
|
||||
->color('success')
|
||||
->icon(null),
|
||||
|
||||
@ -22,8 +22,7 @@ protected function getHeaderActions(): array
|
||||
|
||||
ExportAction::make()
|
||||
->exports([
|
||||
IssueManagementExcelExport::make()
|
||||
->fromTable(),
|
||||
IssueManagementExcelExport::make(),
|
||||
])
|
||||
->color('success')
|
||||
->icon(null),
|
||||
|
||||
@ -25,8 +25,7 @@ protected function getHeaderActions(): array
|
||||
|
||||
ExportAction::make()
|
||||
->exports([
|
||||
MediaMonitoringExcelExport::make()
|
||||
->fromTable(),
|
||||
MediaMonitoringExcelExport::make(),
|
||||
])
|
||||
->color('success')
|
||||
->icon(null),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user