Example #1
0
 public function product($id)
 {
     // Product Detail
     $product = Product::find($id);
     $producer = Producer::find($product->producer);
     $producerItem = "<a href='" . URL::to('/') . "/producer/" . $producer->id . "/" . strtolower($producer->producer) . ".html'>" . $producer->producer . "</a>";
     // Category
     $productCategoryID = Product::find($id)->category_id;
     // breadcrumb
     $breadcrumb = $this->breadcrumb($productCategoryID, $id);
     // Best Seller
     $bestSeller = $this->bestSeller();
     $image = Images::where('productID', $product['id'])->first();
     $thumbnail = $image['imageSrc'];
     $thumbnailImage = '<a class="preView" rel="' . URL::to('/') . '/' . $thumbnail . '"><img src="' . URL::to('/') . '/' . $thumbnail . '" alt="" class="img-responsive"></a>';
     $images = Images::where('productID', $id)->get();
     $listImages = "";
     foreach ($images as $image) {
         $img = $image['imageSrc'];
         $listImages .= '<a href="' . URL::to('/') . '/' . $img . '" class="fancybox-button" rel="photos-lib"><img alt="Berry Lace Dress" src="' . URL::to('/') . '/' . $img . '"></a>';
     }
     $review = '<div class="fb-comments" data-href="' . URL::to('/') . '/product/' . $id . '"
             data-num-posts="10" data-width="700px"></div>';
     return view('home.product.detail')->with(['breadcrumb' => $breadcrumb, 'product' => $product, 'producer' => $producerItem, 'bestSeller' => $bestSeller, 'thumbnailImage' => $thumbnailImage, 'listImages' => $listImages, 'review' => $review]);
 }
 public function update($data)
 {
     $producer = null;
     if (isset($data['id'])) {
         if (isset($data['password_confirmation'])) {
             unset($data['password_confirmation']);
         }
         if (isset($data['password'])) {
             if ($data['password'] == config('admin.password_mask') || !$data['password']) {
                 unset($data['password']);
             }
         }
         if ($producer = Producer::find($data['id'])) {
             $producer->update($data);
         }
     }
     return $producer;
 }
Example #3
0
 public function allProductInCategory($id = 0, $type = "", $order = "")
 {
     $this->allCategoryId($id);
     if ($type == "all" and $order == "") {
         $products = DB::table('product')->whereIn('category_id', $this->allID)->paginate(9)->toArray();
     } else {
         if ($type == "name" and $order == "asc") {
             $products = DB::table('product')->whereIn('category_id', $this->allID)->orderBy("name", "asc")->paginate(9)->toArray();
         } else {
             if ($type == "name" and $order == "desc") {
                 $products = DB::table('product')->whereIn('category_id', $this->allID)->orderBy("name", "desc")->paginate(9)->toArray();
             } else {
                 if ($type == "price" and $order == "asc") {
                     $products = DB::table('product')->whereIn('category_id', $this->allID)->orderBy("price", "asc")->paginate(9)->toArray();
                 } else {
                     if ($type == "price" and $order == "desc") {
                         $products = DB::table('product')->whereIn('category_id', $this->allID)->orderBy("price", "desc")->paginate(9)->toArray();
                     }
                 }
             }
         }
     }
     $allProduct = array();
     foreach ($products['data'] as $product) {
         $allProduct[] = $product;
     }
     $allProductInView = "";
     foreach ($allProduct as $item) {
         $description = $item->description;
         $producerName = Producer::find($item->producer)->producer;
         $images = Images::where('productID', $item->id)->first();
         $thumbnail = $images['imageSrc'];
         $allProductInView .= '<div class="col-md-4 col-sm-6 col-xs-12">';
         $allProductInView .= '<div class="thumbnail">';
         $allProductInView .= '<a class="preview" rel="' . URL::to('/') . '/' . $thumbnail . '" href="' . URL::to('/product') . '/' . $item->id . '/' . $item->name . '.html" class="post-image-link">';
         $allProductInView .= '<p><img src="' . URL::to('/') . '/' . $thumbnail . '" class="img-responsive" alt="' . strtolower($item->name) . '"></p>';
         $allProductInView .= '</a>';
         $allProductInView .= '<div class="caption">';
         $allProductInView .= '<h3><a href="' . URL::to('/product') . '/' . $item->id . '/' . strtolower($item->name) . '.html">' . $item->name . '</a></h3>';
         $allProductInView .= substr($description, 0, 70) . '<br>';
         $allProductInView .= '<span class="btn btn-default"><i class="fa fa-cart"></i>' . $item->price . '$</span>';
         $allProductInView .= '<a href="' . URL::to('/') . '/producer/' . $item->producer . '" class="btn btn-primary">' . $producerName . '</a>';
         $allProductInView .= '</div>';
         $allProductInView .= ' </div></div>';
     }
     return $allProductInView;
 }
Example #4
0
 public function ProductList($id)
 {
     $result = Producer::find($id);
     $producerName = $result->producer;
     return view('admin.producer.product_list')->with(['producerID' => $id, 'producerName' => $producerName]);
 }
Example #5
0
 public function allProducts($type = "", $id = 0, $search = "")
 {
     if ($type == "new") {
         $products = DB::table('product')->orderBy('id', 'desc')->paginate(4)->toArray();
     } else {
         if ($type == "best_seller") {
             $products = DB::table('product')->orderBy('purchase', 'desc')->paginate(4)->toArray();
         } else {
             if ($type == 'search') {
                 $products = DB::table('product')->where('name', 'LIKE', '%' . $search . '%')->paginate(8)->toArray();
             }
         }
     }
     $allProduct = array();
     foreach ($products['data'] as $product) {
         $allProduct[] = $product;
     }
     $allProductInView = "";
     foreach ($allProduct as $item) {
         $description = $item->description;
         $producerName = Producer::find($item->producer)->producer;
         $images = Images::where('productID', $item->id)->first();
         $thumbnail = $images['imageSrc'];
         $allProductInView .= '<div class="col-lg-3 col-sm-6">';
         $allProductInView .= '<div class="thumbnail">';
         $allProductInView .= '<a class="preview" rel="' . URL::to('/') . '/' . $thumbnail . '" href="' . URL::to('/product') . '/' . $item->id . '/' . $item->name . '.html" class="post-image-link">';
         $allProductInView .= '<p><img src="' . URL::to('/') . '/' . $thumbnail . '" class="img-responsive" alt="' . strtolower($item->name) . '"></p>';
         $allProductInView .= '</a>';
         $allProductInView .= '<div class="caption">';
         $allProductInView .= '<h3><a href="' . URL::to('/product') . '/' . $item->id . '/' . strtolower($item->name) . '.html">' . $item->name . '</a></h3>';
         $allProductInView .= substr($description, 0, 70) . '<br>';
         $allProductInView .= '<span class="btn btn-default"><i class="fa fa-cart"></i>' . $item->price . '$</span>';
         $allProductInView .= '<a href="' . URL::to('/') . '/producer/' . $item->producer . '/' . strtolower($producerName) . '.html" class="btn btn-primary">' . $producerName . '</a>';
         $allProductInView .= '</div>';
         $allProductInView .= ' </div></div>';
     }
     return $allProductInView;
 }