Skip to content

Instantly share code, notes, and snippets.

@M4R14
Last active May 10, 2018 15:26
Show Gist options
  • Select an option

  • Save M4R14/8b7b6f091a9fdf278dc1389b9153bff1 to your computer and use it in GitHub Desktop.

Select an option

Save M4R14/8b7b6f091a9fdf278dc1389b9153bff1 to your computer and use it in GitHub Desktop.
Laravel 5 Simple Export CSV
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Excel;
use App\Models\Appointment;
public function export()
{
$datalist = Appointment::get();
$report15 = function ($excel) use ($datalist) {
$excel->sheet('mySheet', function ($sheet) use ($datalist) {
$sheet->fromArray($datalist);
});
}
return Excel::create('report15', $report15)->download('csv');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment