【发布时间】:2017-04-10 18:11:02
【问题描述】:
我尝试在我的电子邮件中附加一个 excel 文件,但我收到一个错误:basename() 期望参数 1 是一个字符串。我在哪里做错了?非常感谢提前!!!!
这里是我的邮件类:
public function build()
{
$licencies = Licencies::where('lb_assurance' , '=' , 'Lafont')->where('created_at' , Carbon::today())->get();
$excel_file = Excel::create('DailyRecapLicencesLafont', function($excel) use ($licencies) {
$excel->sheet('Excel', function($sheet) use ($licencies) {
$sheet->fromArray($licencies);
});
});
return $this->markdown('email.licences.lafont')->attach($excel_file , 'excel.xls');
}
【问题讨论】:
-
$excel_file 是一个对象,attach() 期望第一个参数是一个字符串,即被附加文件的路径
-
感谢您的回答,您知道实现我想做的最好的方法吗?
标签: laravel