1. Go to this page and download the library: Download moonshine/import-export library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moonshine / import-export example snippets
/**
* @extends ModelResource<Category>
*/
class CategoryResource extends ModelResource implements HasImportExportContract
{
use ImportExportConcern;
// ...
}
/**
* @extends ModelResource<Category>
*/
class CategoryResource extends ModelResource implements HasImportExportContract
{
use ImportExportConcern;
// ...
protected function exportFields(): iterable
{
return [
ID::make(),
Position::make(),
Text::make('Name'),
];
}
protected function importFields(): iterable
{
return [
ID::make(),
Text::make('Name'),
];
}
}
public function beforeImportFilling(array $data): array
{
return $data;
}
public function beforeImported(mixed $item): mixed
{
return $item;
}
public function afterImported(mixed $item): mixed
{
return $item;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.