0

I have installed laravel backpack on my local. I am trying to modify the filename of exported file with this format TableName _YYYY-MM-DD HH:MM:SS. But can't find the option to do that in backpack.

Here's what I add for adding the export button in my table Controller.

$this->crud->enableExportButtons();
Edz
  • 1
  • 1

1 Answers1

3

To my knowledge, the exported file is created in the client, it's a DataTables feature, that's why you can set a custom filename in the export_buttons.blade.php view file.

The vendor file is vendor/backpack/crud/src/resources/views/crud/inc/export_buttons.blade.php, you should probably copy that to resources/views/vendor/backpack/crud/inc/export_buttons.blade.php and edit the latter.

There is an array of buttons in the config options of window.crud.dataTableConfiguration.buttons. Each of the buttons has multiple properties like name, extend, exportOptions, action. Add another option title to the button you want to set the filename for.

title: '{{$crud->model->getTable().'_'.now()->format('Y-m-d H:i:s')}}', will get you something pretty close to what you want I hope.

mattsches
  • 583
  • 4
  • 6
  • Can confirm! The export is done by DataTables, using js (in the client). Thanks for the answer Matt! – tabacitu Mar 21 '23 at 16:03