Sunday, April 9, 2017

Mail methode in a cronjob task command

Hello I try to send an email with an excel file from a command but it's seems to doesn't work

i get this exception when i try to run the artisan command :

Call to undefined method Illuminate\Mail\PendingMail::subject()

someone now how to resolve the problem ? thanks a lot in advance

here my command :

 public function handle()
 {
     $user = Auth::user();

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

        Mail::to($user)
            ->subject('Licences Lafont Daily')
            ->from('test@test.fr')
            ->attach($excel_file , 'LaFontDaily.xls')
            ->send();

        $this->info('Lafont task Done');
    }



via Mathieu Mourareau

Advertisement