Download the PHP package underwear/laravel-excel-import without Composer
On this page you can find all versions of the php package underwear/laravel-excel-import. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download underwear/laravel-excel-import
More information about underwear/laravel-excel-import
Files in underwear/laravel-excel-import
Package laravel-excel-import
Short Description Simple import from excel for Laravel
License
Informations about the package laravel-excel-import
laravel-excel-import
Easily import xlsx file right into you database just with some code lines! Validate your data with default laravel validator and search related values from other tables.
Supported Columns Types
Text
You can add validation rules:
Or even add your own closure to mutate value
Slug
You can generate slug from text
Boolean
Autoincrement
Do not uses xls cells to get value. Just generates by it owns.
BelongsTo
Closure
Do not uses xls cells to get value. Just returns value
Faker
Use can also use fzaninotto/Faker
Installation
You can install the package via composer:
Usage example
Imagine we need to import some articles from xlsx file.
Xlsx file has some fields like:
- "title" (A column)
- "body" (B column)
- "category name" (C column)
- "is_published" (D column) with values "yeap" if true
DB table has columns:
- (int) id
- (string) title
- (string) slug
- (int fk) category_id
- (bool) is_published
- (int) order_column
use Underwear\Import\Import;
use Underwear\Import\Elements\Text;
use Underwear\Import\Elements\BelongsTo;
use Underwear\Import\Elements\Boolean;
use Underwear\Import\Elements\Autoincrement;
Import::make('articles', [
Text::make('title', 'A')
->rules(['filled']),
Slug::make('slug', 'A'),
BelongsTo::make('category_id', 'C', 'categories' , 'title', 'id'),
Boolean::make('is_published', 'D')
->trueValue('yeap'),
Autoincrement::make('order_column'),
])->parseFile('/path/to/articles.xlsx')