aliportfolio / csv-importer
The package allows you to upload a CSV file and import the data into database.
v1.0.0
2023-06-03 04:04 UTC
Requires
- php: >=8.0
- illuminate/support: >=8.0
- league/csv: >=9.8
This package is not auto-updated.
Last update: 2025-03-23 10:43:47 UTC
README
The package allows you to upload a CSV file and import the data into database.
Features
- CSV Importer
- TXT Importer
- Fields Validator
Installation
Install with command
composer require aliportfolio/csv-importer
Usage/Examples
First, create custom importer (ex: CategoryImport.php)
<?php namespace App\Imports; use Aliportfolio\CsvImporter\CsvImporter; class CategoryImport extends CsvImporter { // Model Name protected $table = 'Category'; protected $mapping = [ 'name' => 'name' ]; // Validation Data protected $rules = [ 'name' => 'required|string' ]; }
In controller call the CategoryImport Class
$import = new CategoryImport(); $import->import($request->file('csv_file'));