使用Markdown Mail附加Excel文件

时间:2017-04-09 18:16:21

标签: laravel

我尝试使用我的电子邮件附加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');
    }

1 个答案:

答案 0 :(得分:2)

试试这个:

     * @Route("")
 */
public function listAction(Request $request)
{
    $list = $this->createList($this->getListObject());
    $list->handleRequest($request)->process();
    $list->setTemplatesScope($this->getTemplatesScope() . ':Listing\\');

    if ($request->isXmlHttpRequest()) {
        return new JsonResponse($list->getInfo());
    } else {
        return $this->render($this->getTemplatesScope().':list.html.twig', $list->render());
    }
}