Import

You're browsing the documentation for an old version of MoonShine. Consider upgrading your project to MoonShine 2.x.

Imports data

use MoonShine\Actions\ImportAction;
 
//...
public function actions(): array
{
return [
ImportAction::make('Import')
// Optional methods
// If you want to run in the background
->queue()
// Selecting a drive
->disk('public')
// Selecting a save directory
->dir('/exports')
// Delete after importing
->deleteAfter()
// If you use csv
->delimiter(',')
,
];
}
//...

Only those fields will be imported that are marked using the useOnImport

//...
public function fields(): array
{
return [
// Be sure to mark the identifier, otherwise all entries will be added and not edited
ID::make()
->useOnImport(),
 
Text::make('Title')
->useOnImport(),
];
}
//...