/** * Execute the job. * @param Excel $excel */ public function handle(Excel $excel) { $excel->create($this->product->code, function ($excel) { $excel->sheet($this->product->code, function ($sheet) { $codes = $this->codes or $this->product->codes()->get(['code']); $sheet->fromArray($codes); }); })->download('xlsx'); }