Lodret
Modal Action Hit Url
Any suggestion how to hit url export i have made in controller after user chose date in modal form
protected function ExportAction()
{
return Action::make('export-excel')
->color('success')
->icon('heroicon-m-variable')
->modalHeading('Export Berita')
->modalAlignment(Alignment::Center)
->modalIcon('heroicon-m-variable')
->modalIconColor('success')
->modalWidth('md')
->modalFooterActionsAlignment(Alignment::End)
->form([
Fieldset::make('Periode Berita')
->schema([
DatePicker::make('tanggal_awal')
->hiddenLabel()
->default(Carbon::now())
->displayFormat('d/m/Y')
->native(false),
DatePicker::make('tanggal_akhir')
->hiddenLabel()
->default(Carbon::now()->endOfMonth())
->displayFormat('d/m/Y')
->native(false),
])
])
->action(function (array $data, Action $action) {
try {
$param = [
'tanggal_awal' => $data['tanggal_awal'],
'tanggal_akhir' => $data['tanggal_akhir'],
];
$aksi = $action->url(route('export.excel.berita', $param), true)->isLink();
} catch (\Throwable $th) {
Log::error('Erorr when export excel code: '. $th->getCode());
Log::error($th->getMessage());
}
});
}
protected function ExportAction()
{
return Action::make('export-excel')
->color('success')
->icon('heroicon-m-variable')
->modalHeading('Export Berita')
->modalAlignment(Alignment::Center)
->modalIcon('heroicon-m-variable')
->modalIconColor('success')
->modalWidth('md')
->modalFooterActionsAlignment(Alignment::End)
->form([
Fieldset::make('Periode Berita')
->schema([
DatePicker::make('tanggal_awal')
->hiddenLabel()
->default(Carbon::now())
->displayFormat('d/m/Y')
->native(false),
DatePicker::make('tanggal_akhir')
->hiddenLabel()
->default(Carbon::now()->endOfMonth())
->displayFormat('d/m/Y')
->native(false),
])
])
->action(function (array $data, Action $action) {
try {
$param = [
'tanggal_awal' => $data['tanggal_awal'],
'tanggal_akhir' => $data['tanggal_akhir'],
];
$aksi = $action->url(route('export.excel.berita', $param), true)->isLink();
} catch (\Throwable $th) {
Log::error('Erorr when export excel code: '. $th->getCode());
Log::error($th->getMessage());
}
});
}
3 replies