Exemple #1
0
 public function showroom(Shop $shop, Request $request)
 {
     $products = $shop->products();
     $categories = $shop->products()->with('category')->groupBy('category_id')->get()->pluck('category.name', 'category.id');
     if ($request->has('keyword')) {
         $keyword = $request->input('keyword');
         if (!empty($keyword)) {
             $products = $products->search($keyword);
         }
     }
     if ($request->has('category_id')) {
         $category_id = $request->input('category_id');
         if (!empty($category_id) and $category_id != 0) {
             $products = $products->where('category_id', $request->input('category_id'));
         }
     }
     if ($request->has('order')) {
         $order = $this->orderToValue($request->input('order'));
         $products = $products->orderBy($order['field'], $order['order']);
     }
     $products = $products->get();
     $input = $request->all();
     return view('shop.showroom', compact('shop', 'products', 'input', 'categories'))->with(['title' => $shop->title]);
 }
Exemple #2
0
 /**
  * Created By Dara on 26/12/2015
  * admin-product management
  */
 public function adminIndex(User $user, Shop $shop)
 {
     $products = $shop->products()->latest()->paginate(20);
     return view('admin.shop.product.index', compact('shop', 'user', 'products'))->with(['title' => 'User Product Management']);
 }