moonshine / import-export
Import/Export Handlers for MoonShine
Installs: 3 079
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- php: ^8.2|^8.3
- ext-curl: *
- ext-json: *
- rap2hpoutre/fast-excel: ^5.4
Conflicts
- laravel/framework: <10.48.0
- moonshine/moonshine: <3.0
This package is auto-updated.
Last update: 2024-12-20 07:16:18 UTC
README
Requirements
- MoonShine 3+
- Laravel 10+
- PHP 8.2+
Installation
composer require moonshine/import-export
Usage
- Add
trait
MoonShine\ImportExport\Traits\ImportExportConcern
andinterface
MoonShine\ImportExport\Contracts\HasImportExportContract
to ModelResource
/** * @extends ModelResource<Category> */ class CategoryResource extends ModelResource implements HasImportExportContract { use ImportExportConcern; // ... }
- Define fields
/** * @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'), ]; } }
- Events
public function beforeImportFilling(array $data): array { return $data; } public function beforeImported(mixed $item): mixed { return $item; } public function afterImported(mixed $item): mixed { return $item; }