在我的 StudentController 上:
//data collection
$all_students= Student::with('Customer')->where('std', $name)->get();
//create a new array
$student_array[] = array();
//loop and set array indexes
foreach ($all_studentsas $student)
{
$student_array[] = array(
'description' => $student['description'],
'cost' => $student['cost']
);
}
return Excel::download('Student_Data', function ($excel) {
$excel->setTitle('Student Data');
$excel->sheet('Student_Data', function ($sheet) {
$sheet->fromArray($student_array);
});
})->download('xls');
我尝试了很多solutions,但无法解决此问题。
类型错误:参数2传递给Maatwebsite \ Excel \ Excel :: download() 必须是字符串类型,给定对象,在 C:\ xampp \ htdocs \ project \ vendor \ laravel \ framework \ src \ Illuminate \ Support \ Facades \ Facade.php 在第221行
有人可以指出我在这里做错了什么,我应该怎么做才能解决此问题?