/** * 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'); }
/** * Check if codes are all unique * @return string */ private function checkDatabase() { /** * Check Against Database to find duplicated Code */ /** @var Collection $duplicated */ $duplicated = $this->product->codes()->whereIn('code', $this->codes->toArray())->get(); if (!$duplicated->isEmpty()) { $duplicated->each(function ($duplicated) { $this->regenerate($duplicated->code); }); } }