PHP code example of mtcmedia / laravel-import
1. Go to this page and download the library: Download mtcmedia/laravel-import 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/ */
mtcmedia / laravel-import example snippets
php artisan import:csv source_map_file_name import_data.csv --header-offset=1
php artisan import:json source_map_file_name import_data.json
php artisan import:xml source_map_file_name import_data.xml
php artisan import:database source_map_file_name import_data.csv --prefix=prfx
'providers' => [
// ...
Mtc\Import\Providers\ImportServiceProvider::class,
];
php artisan import:csv source_map_file_name import_data.csv --header-offset=1
php artisan import:json source_map_file_name import_data.json
php artisan import:xml source_map_file_name import_data.xml
php artisan import:database source_map_file_name import_data.csv --prefix=prfx
class Item extends Model {
use Mtc\Import\Traits\Importable;
...
protected $importable_defaults = [
'price' => 0,
'sort_price' => 0,
];
protected $importable_relationships = [
'images' => [
'type' => HasMany::class,
'model' => Image::class,
],
'custom' => [
'type' => HasOne::class,
'model' => Custom::class,
],
];