示例#1
0
 public function getProduct($id = null)
 {
     //preparing modell
     $categories = Category::all();
     if (!is_null($id)) {
         $products = Product::where('cat_id', '=', $id)->get();
     } else {
         $products = Product::all();
     }
     return View::make('products', compact('categories', 'products'));
 }
 public function index()
 {
     $products = Product::all();
     $popularProducts = [];
     return view('products', compact('products', 'popularProducts'));
 }