Import & Export
SeviaFlow's current Resource import and export flow uses CSV. You configure the fields on the Resource, then operators use the actions on the Resource index page. These are UI workflows, not standard CRUD API endpoints.
Export selected Resource data
Return an enabled ExportResource from the Resource's export() method. The allowlist controls which model fields the export can include; it is separate from the table columns and API readable fields.
use SeviaFlow\Core\Resources\ExportResource;
public static function export(ExportResource $export): ExportResource
{
return $export
->enabled()
->allowedFields(['id', 'name', 'email', 'status'])
->formats(['csv']);
}
- Choose the fields an operator is allowed to export.
- Enable export for the Resource and keep the available format at
csv. - On the Resource index, start the export. SeviaFlow applies the configured row limit and streams a CSV download.
The CSV uses UTF-8 and includes a byte order mark for spreadsheet compatibility. Values beginning with =, +, -, or @ are escaped to reduce spreadsheet formula injection risk.
Import a CSV file
CSV import creates new model records. It does not update or upsert existing records. Configure an explicit field allowlist, required fields, and whether to reuse the Resource form field rules:
use SeviaFlow\Core\Resources\ImportResource;
public static function import(ImportResource $import): ImportResource
{
return $import
->enabled()
->allowedFields(['name', 'email', 'status'])
->requiredFields(['name', 'email'])
->useFormFieldRules();
}
- Prepare a CSV whose first row contains column names matching the allowed field names, such as
name,email,status. - Upload it from the Resource index. The preview shows the headers and a sample of rows, and reports missing required headers or unknown fields.
- Review the preview and correct the file if needed. Required values and the configured field validation rules are checked before records are written.
- Confirm the import. If a header or row fails validation, SeviaFlow reports the errors and does not write a partially valid set of rows. If validation passes, the new records are created in a database transaction.
File fields cannot be imported from CSV. The import limit applies to the full file, while the preview limit controls how many rows are shown before confirmation.
Configure and understand the limits
| Setting | Default | What it limits |
|---|---|---|
export.max_rows | 5000 | Maximum rows in one export. Narrow the list or selection if it is exceeded. |
import.max_rows | 1000 | Maximum data rows accepted from one CSV import. |
import.preview_rows | 20 | Maximum sample rows displayed in the preview. |
These settings are in config/seviaflow.php. See Configuration Reference for publishing and editing package configuration.
Get Started