コード例 #1
0
 /**
  * Display product's details page.
  *
  * @param $product
  *
  * @return Response
  */
 public function product($product)
 {
     $categories = Category::get()->sortBy('name');
     $paginate = Product::paginate(6);
     $products = $paginate->items();
     $product = Product::findByName($product)->get()->first();
     return view('product.index', compact('product', 'products', 'categories'));
 }
コード例 #2
0
 /**
  * Execute the command.
  *
  * @param Request $request
  */
 public function handle(Request $request)
 {
     $client = new GoutteClient();
     $slug = $request->input('slug');
     $categories = $request->input('categories');
     $crawler = $client->request('GET', self::BASE_URL . '/' . $slug);
     $products = $this->getProducts($crawler);
     foreach ($products as $product) {
         if ($this->saveProductImage($client, $product['url'], $product['slug'], $product['ext'])) {
             $product = Product::create(['name' => $product['item'], 'image' => $product['slug'] . '.' . $product['ext'], 'description' => $product['item'], 'price' => $product['price'], 'status' => 0, 'quantity' => 0]);
             foreach ($categories as $category) {
                 $product->category()->attach($category);
             }
         }
     }
 }
コード例 #3
0
 /**
  * Delete Product.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $product = Product::findOrFail($id);
     $product->destroy();
 }
コード例 #4
0
ファイル: SiteUser.php プロジェクト: jbmadking/bottlestore
 public function products()
 {
     return Product::all();
 }