I am using Laravel 5.4 and I want to export a record to a excel file but I got this error
Argument 1 passed to Illuminate\Database\Eloquent\Builder::create() must be of the type array, string given, called in C:\xampp\htdocs\www\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 1332 and defined
and here is my code:
$export = Student::all();
Excel::create('Export Excel',function($excel) use($export){
$excel->sheet('Sheet 1', function($sheet) use($export){
$sheet->fromArray($export);
});
})->download('xlsx');
$export = Student::all();
Excel::create('Export Excel',function($excel) use($export){
$excel->sheet('Sheet 1', function($sheet) use($export){
$sheet->fromArray($export);
});
})->download('xlsx');