Sunday, April 9, 2017

Attach Excel File with Markdown Mail

I try to attach an excel File with my email but i get an error : basename() expects parameter 1 to be a string . Where i am doing wrong ? thanks a lot in advance !!!!

here my Mail Class :

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');
    }



via Mathieu Mourareau

Advertisement