示例#1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $brands = Brand::all();
     foreach ($brands as $brand) {
         $url = $brand->danawa;
         $count = $this->parseWebData($url, $brand);
         if ($count == 20) {
             $url = $brand->danawa . '&Page=2';
             $count += $this->parseWebData($url, $brand);
         }
         $this->info('Processing ' . $brand->brand_name . '(' . $count . ')' . "\n");
     }
     //$this->manualInsertion();
 }
示例#2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $brands = Brand::all();
     $arrPromos = $this->aggregatePromoDataFromWeb();
     foreach ($brands as $brand) {
         $this->info('Processing ' . $brand->brand_name . "\n");
         $date = date('Ym');
         $brand_id = $brand->id;
         // $this->info($brand->brand_name."\n");
         if (array_has($arrPromos, $brand->brand_name)) {
             $models = $arrPromos[$brand->brand_name];
             foreach ($models as $key => $value) {
                 $conditions = implode('|', $value);
                 $promo = Promo::updateOrCreate(['brand_id' => $brand_id, 'date' => $date, 'name' => $key, 'conditions' => $conditions], []);
                 // $brand->promos()->save($promo);
             }
         }
     }
 }