예제 #1
0
 public function allProducers($type, $id)
 {
     $allProducers = "";
     $producers = App\Producer::all()->toArray();
     $listProducers = array();
     foreach ($producers as $value) {
         $listProducers[] = $value;
     }
     foreach ($listProducers as $producer) {
         if ($type == 'create') {
             $allProducers .= "<option value='" . $producer['id'] . "'>";
         } else {
             if ($type == 'edit') {
                 if ($producer['id'] == $id) {
                     $allProducers .= "<option value='" . $producer['id'] . "' selected>";
                 } else {
                     $allProducers .= "<option value='" . $producer['id'] . "'>";
                 }
             }
         }
         $allProducers .= $producer['producer'];
         $allProducers .= "</option>";
     }
     return $allProducers;
 }
예제 #2
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 getProductsByProducerKey($producerKey = '', $limit = 0)
 {
     $producer = Producer::where('key', $producerKey)->first();
     if (isset($producer) && !is_null($producer)) {
         if ($limit == 0) {
             return $producer->products()->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->get();
         } else {
             return $producer->products()->where('is_publish', 1)->orderBy('priority')->orderBy('created_at', 'desc')->take($limit)->get();
         }
     }
     return [];
 }
예제 #4
0
 public function create($data)
 {
     $producer = Producer::create($data);
     if ($data['token']) {
         $producer_logo = ProducerLogo::whereProducerToken($data['token'])->first();
         if ($producer_logo) {
             $producer_logo->producer_id = $producer->id;
             $producer_logo->save();
         }
     }
     return $producer;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     DB::transaction(function () use($id) {
         $user = Auth::user();
         $producer = Producer::findOrFail($id);
         $producer->updated_by = $user->name;
         $producer->deleted_by = $user->name;
         $producer->key = $producer->key . '-' . microtime(true);
         $producer->save();
         // soft delete
         $producer->delete();
     });
 }
예제 #6
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;
 }
예제 #7
0
 public function ProductList($id)
 {
     $result = Producer::find($id);
     $producerName = $result->producer;
     return view('admin.producer.product_list')->with(['producerID' => $id, 'producerName' => $producerName]);
 }
예제 #8
0
 public function index()
 {
     $username = Auth::user()->name;
     $data = array('users' => App\Users::count(), 'products' => App\Product::count(), 'orders' => App\Order::count(), 'producers' => App\Producer::count());
     return view('admin.dashboard.index', compact('data'))->with(['username' => $username]);
 }
예제 #9
0
 public function brands()
 {
     $producers = Producer::all()->toArray();
     $brands = "";
     foreach ($producers as $index => $item) {
         $brands .= ' <div class="owl-item active" style="width: 163px;"><a href="' . URL::to('/') . '/producer/' . $item['id'] . '/' . strtolower($item['producer']) . '.html"><img
                                 src="' . $item['logo'] . '" alt="' . $item['producer'] . '"
                                 title="' . $item['producer'] . '"></a>
                 </div>';
     }
     return $brands;
 }
예제 #10
0
 public function update($data)
 {
     $sample = null;
     if (isset($data['id'])) {
         if ($sample = Sample::find($data['id'])) {
             $sample->update($data);
             if (isset($data['producer_id'])) {
                 if ($data['producer_id'] == 'new') {
                     unset($data['producer_id']);
                     $producer = new Producer();
                     $producer->name = $data['producer__name'];
                     $producer->customer_id = $sample->customer_id;
                     $producer->contact_person = $data['producer__contact_person'];
                     $producer->email = $data['producer__email'];
                     $producer->phone = $data['producer__phone'];
                     $producer->save();
                     $sample->producer_id = $producer->id;
                     $sample->save();
                 }
             }
             if (isset($data['varietals'])) {
                 if (is_array($data['varietals'])) {
                     $sample->sample_varietals()->delete();
                     foreach ($data['varietals'] as $varietal_data) {
                         if ($varietal_data['name'] && $varietal_data['percentage']) {
                             $sample_varietal = $sample->sample_varietals()->save(new SampleVarietal($varietal_data));
                         }
                     }
                 }
             }
             if (isset($data['prizes'])) {
                 if (is_array($data['prizes'])) {
                     foreach ($data['prizes'] as $prize_data) {
                         if ($prize_data['id']) {
                             $sample_prize = SamplePrize::find($prize_data['id']);
                             $sample_prize->name = $prize_data['name'];
                             $sample_prize->year = $prize_data['year'];
                             $sample_prize->save();
                         } elseif ($prize_data['name']) {
                             $sample_prize = $sample->sample_prizes()->save(new SamplePrize($prize_data));
                         }
                     }
                 }
             }
             $sample = $this->getById($data['id']);
         }
     }
     return $sample;
 }