Exports
Resources can be exported to files (pdf, xlsx etc.) from the index page.
Fields
By default, the data for each field will be exported based on the raw database column value.
Export value
You can however change the export value for each field:
Text::make(__('Last name'), 'last_name')
->exportUsing(function($value, $model, $type) {
if ($type === 'xlsx') {
return $value;
}
return $model->{someOtherData};
})
Where $type
is the export type.
Disable exporting
You can disable exporting for a field:
Text::make(__('Last name'), 'last_name')
->hideOnExport(true)
Excel export arguments
Sometimes you want your field to use a specific formatter and currency code for Excel exports:
$this->withExportMeta([
'formatter' => ExportFormat::PRICE_WITHOUT_CURRENCY
]);
$this->withExportMeta([
'formatter' => ExportFormat::PRICE_WITH_CURRENCY,
'currency_code' => setting('qore/invoicing', 'currency_code', preference('currency'))
]);
At this moment in time, only the above export meta options are supported.
Background downloads
Exporting large amounts of rows will take time. When there are more than 5000 rows exported,
a background downloader will start (as a dispatched job).
When you have your QUEUE_CONNECTION
on sync
, exports will always be immediate.