public static function setData(CellCollection $v)
 {
     $product = Product::whereCode($v->product_code)->first();
     return ['group' => $v->group, 'number' => $v->number, 'product_id' => $product->id, 'product_code' => $product->code, 'mix_no' => $product->mix_no, 'product_description' => $product->description, 'qty' => $v->qty, 'unit' => $v->unit, 'remark' => $v->remark];
 }
Example #2
0
 public static function setData(CellCollection $v)
 {
     $product = Product::whereCode($v->product_code)->first();
     $location = Location::whereName($v->location)->first();
     return ['product_id' => $product->id, 'product_code' => $product->code, 'mix_no' => $product->mix_no, 'product_description' => $product->description, 'location_id' => $location->id, 'location_name' => $location->name, 'qty' => $v->qty, 'remark' => $v->remark];
 }
Example #3
-1
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     // parse url
     $url = $this->parseURLPDF();
     // Parse pdf file and build necessary objects.
     $parser = new \Smalot\PdfParser\Parser();
     $pdf = $parser->parseFile($url);
     $pages = $pdf->getPages();
     foreach ($pages as $page) {
         $p = new ParsePage($page->getArray());
         $products = $p->parseProducts();
         foreach ($products as $product) {
             $p = Product::whereCode($product['code'])->first();
             if (is_null($p)) {
                 $p = new Product();
             }
             $p->fill($product);
             $p->save();
         }
     }
 }