niiyz / laravel-csv
Laravel5 Simple CSV Downloader
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 10 088
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 0
README
Laravel-CsvDownloader is Very Simple Csv Downloader
#Installation
Require this package in your composer.json
and update composer.
"niiyz/laravel-csv": "~1.0.1"
After updating composer, add the ServiceProvider to the providers array in config/app.php
'Niiyz\Csv\CsvServiceProvider',
You can use the facade for shorter code. Add this to your aliases:
'Csv' => 'Niiyz\Csv\Facades\Csv',
The class is bound to the ioC as csv
use Csv;
Sample.1
Csv::create([[1, 2, 3], [10, 20, 30]], []); Csv::convertEncoding('UTF-8', 'SJIS-win');// ex. Japanese return Csv::download('sample.csv');
Sample.2
$users = \User::where('type', '=', '1')->get(['name', 'birth_day'])->toArray();// from DB $header = ['customer', 'birthday']; Csv::create($users, $header); Csv::convertEncoding('UTF-8', 'SJIS-win');// ex. Japanese return Csv::download('customers.csv');