2017-10-14 63 views
0

我有一个数据库充满了用户,在后端我有一个按钮来收集我的数据库并将其下载为一个Excel文件。 (使用Maatwebsite)。同时,我希望管理员能够收到带有此Excel文件的电子邮件。我如何将这个栏目添加到电子邮件中? 这是代码:下载和邮件Excel文件Laravel

public function excel() 
{ 
    Excel::create('Participants', function($excel) { 

     $excel->sheet('Participants', function($sheet) { 

      $sheet->fromArray(Participant::where('enabled',1)->get(), null, 'A1', false, false); 

     }); 
    })->download("xlsx"); 
    Mail::raw("In attachment excelfile of participants ", function($message) 
    { 
     $message->subject('ExcelFile Participants!'); 
     $message->from('[email protected]', 'As Adventure Contest'); 
     $message->to('[email protected]'); 
     //$message->attachData(, 'Participants.xlsx'); 
    }); 
} 

回答