/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $shops = $this->shopRepository->findAll();
     // assign 3 shipping plans with 3 shipping optinos each to 80% of shops
     foreach ($shops as $shop) {
         if ($this->faker->boolean(20)) {
             continue;
         }
         /** @var Shop $shop */
         $shop->shippingPlans()->saveMany(factory(ShippingPlan::class, 3)->make())->each(function ($shippingPlan) {
             /** @var ShippingPlan $shippingPlan */
             $shippingPlan->shippingOptions()->saveMany(factory(ShippingOption::class, 3)->make());
         });
     }
     // assign shipping plan to each product if owner has any
     // or 0 if owner doesn't
     $products = $this->productRepository->with('owner.shippingPlans')->findAll();
     foreach ($products as $product) {
         /** @var Seller $seller */
         $seller = $product->seller;
         if ($seller->shippingPlans->count()) {
             /** @var Product $product */
             $product->shippingPlans()->attach($seller->shippingPlans->random()->id);
         }
     }
 }
示例#2
0
 public function show(User $user)
 {
     if (!$user->isVerified()) {
         abort(404);
     }
     $products = $this->productRepository->whereSeller($user)->scopes('active')->with('image', 'categories')->paginate(10);
     return view('user::__front.show', compact('user', 'products'));
 }
示例#3
0
 public function show(Shop $shop)
 {
     /*if (! $shop->isVerified()) {
           abort(404);
       }*/
     $products = $this->productRepository->whereSeller($shop)->scopes('active')->with('image', 'categories')->paginate(10);
     return view('shop::__front.shops.show', compact('shop', 'products'));
 }
 public function update(ProductStockRequest $request, Product $product)
 {
     $stock = $request->input('stock');
     if ($stock === "") {
         $stock = null;
     }
     $this->productRepository->update($product, ['stock' => $stock]);
     return $this->ajaxSuccess();
 }
示例#5
0
 public function index()
 {
     $products = $this->productRepository->latest('updated_at')->paginate(20);
     return view('product::__admin.products.index', compact('products'));
 }