imediasun/laravel-csv-import is a Laravel package for package for using widgets in laravel-5.
It currently has 0 GitHub stars and 16 downloads on Packagist.
Install it with composer require imediasun/laravel-csv-import.
Discover more Laravel packages by imediasun
or browse all Laravel packages to compare alternatives.
Last updated
COMMAND-LINE AND API BASED CSV IMPORT TOOL WITH AN ADMIN USER INTERFACE
This package allows you to import CSV files a database.
This package can be used in Laravel 5.6 or higher. You can install the package via composer:
composer require imediasun/laravel-csv-import
manually add the service provider in your config/app.php file:
'providers' => [
// ...
Imediasun\Widgets\WidgetServiceProvider::class,
];
You can publish the package with:
php artisan vendor:publish --provider="Imediasun\Widgets\WidgetServiceProvider"
Also you need run migrate in Laravel:
php artisan migrate
After that you need to set widget config variables in congig/widgets.php:
return [
// ...
'csv_import_recepient'=>'[email protected]',
'csv_import_sender'=>['address'=>'[email protected]','name'=>'Andrey'],
];
To check, add to any template that you are going to display, for example, the line in the resources \ views \ welcome.blade.php:
@widget('test')
You can see Log files after laravel Queues jobs will proceed in storage/logs/csv_import_exception.log
Also you can use this package in your code in such format:
use Imediasun\Widgets\ApiController as Import;
$importer = new Import();
$importer->setDestination('customers');
$importer->setSource(storage_path('app/csv/zIZSaoFkwDMY2Jchp9AOYanBFvL2mfcKfalbn4uI.csv'));
$importer->configureFields([
'Name'=>['field'=>'name','validators'=>'required|max:255'],
'Email'=>['field'=>'email','validators'=>'required|email'],
'Telefon'=>['field'=>'telefon','validators'=>'max:10']
]);
$result = $importer->process();
this package can add values to the database by defining names in the header of CSV file If csv didnt contains header this package will catch exception and you will receive exception message For simple import sample file you can find in root folder of the package customers.csv Also Package use Laravel Queue and you need to set up them on your Laravel project. To receive success and error emails you need to configure your mail server in .env file For Example like this
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=mail@gmail.com
MAIL_PASSWORD=Password
MAIL_ENCRYPTION=tls
There is a test folder in app/Widgets dirrectory You can set up your PhpStorm or other IDE that you use to run test that this folder conteins