okamok / csv-download-library
For Laravel CSV file download
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/okamok/csv-download-library
Requires
- php: ^7.0
- laravel/framework: ^5.0.0
README
CSV file download library.
Installation
Via Composer
$ composer require okamok/csv-download-library
Usage
This is sample controller for Laravel
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Okamok\CsvDownloadLibrary\CsvCreate; //csv-download-library use Illuminate\Support\Facades\Response; class TopController extends Controller { public function index(Request $request) { //sample header $csvHeader = ['title1','title2','title3']; //sample data(All users data) $data = User::get()->toArray(); //you also can use Array for data //$data = [['aaa','bbb','ccc'], ['ddd','eeee','ffff']]; //sample file name $fileName = 'test.csv'; //use this library $ret = CsvCreate::getCsvData($data, $csvHeader, $fileName, 'UTF-8'); //CSV output return Response::make($ret['csv'], 200, $ret['headers']); } }
License
The MIT License (MIT).