Example #1
0
 protected function brands($brands)
 {
     foreach ($brands as $brand) {
         $file = $this->image($brand->name, $brand->brands);
         $existing = Brand::create(['nl' => ['name' => $brand->name], 'en' => ['name' => $brand->name], 'fr' => ['name' => $brand->name], 'de' => ['name' => $brand->name]]);
         $this->dispatch(new StoreNewImage(null, $existing, $file));
     }
 }
Example #2
0
 protected function productBases($amount)
 {
     $brands = Brand::all();
     $categories = Category::whereNull('original_id')->get();
     $categories->load('synonyms');
     $accounts = Account::take(2)->get();
     foreach ($accounts as $account) {
         for ($i = 0; $i < $amount; $i++) {
             $product = factory(Product::class)->create(['brand_id' => $brands->random(1)->id, 'account_id' => $account->id]);
             $this->addImages($product);
             $category = $categories->random(1);
             $categoryIds = [$category->id];
             if ($category->synonyms) {
                 $categoryIds = array_merge($categoryIds, $category->synonyms->lists('id')->toArray());
             }
             $product->categories()->sync($categoryIds);
             $this->properties($product, $category);
             $this->prices($product, $account->id);
             $this->promotions($product, $account->id);
         }
     }
 }
Example #3
0
 /**
  *
  */
 protected function brand()
 {
     $brand = BrandTranslation::where('name', 'Philips')->first();
     if (!$brand) {
         $brand = Brand::create(['nl' => ['name' => 'Philips'], 'en' => ['name' => 'Philips']]);
         $brand = $brand->id;
         return $brand;
     } else {
         $brand = $brand->brand_id;
         return $brand;
     }
 }
 /**
  * @param $payload
  * @return array
  */
 protected function response($payload)
 {
     $brand = $this->brand->with('translations')->find($payload['brand_id']);
     $category = $this->category->with('translations')->find($payload['category_id']);
     return ['category' => $category->toArray(), 'brand' => $brand->toArray()];
 }
Example #5
0
 /**
  * @param Request $request
  * @param AccountManager $manager
  * @param Brand $brands
  */
 public function brand(Request $request, AccountManager $manager, Brand $brands)
 {
     $activate = $request->get('status');
     $brand = $brands->findOrFail($request->get('brand'));
     if ($activate) {
         $this->dispatch(new ActivateBrand($brand, $manager->account()));
     } else {
         $this->dispatch(new DeactivateBrand($brand, $manager->account()));
     }
 }
Example #6
0
 /**
  * @param BrandSelection $selection
  */
 public function handle(BrandSelection $selection)
 {
     $instance = $selection->newInstance(['account_id' => $this->account->id]);
     //create the selections
     $this->brand->selection()->save($instance);
 }