/** * Show the application dashboard to the user. * * @return Response */ public function detail($slug) { $explodeSlug = explode('-', $slug); $product_id = explode('.', end($explodeSlug))[0]; if (!$product_id) { return View::make('errors/503'); } $model = new Product(); $product = $model->getAll()->where('id', $product_id)->first(); if (empty($product)) { return View::make('errors/503'); } $relatedProduct = $model->getAll()->where('category_id', $product->category_id)->get(); $data = ["title" => $product ? $product->name : '', 'product' => $product, 'keywords' => $product ? $product->keywords : '', "description" => $product ? $product->description : '', 'releated_product' => $relatedProduct]; return View::make('user/detail_product', $data); }
public function getShow(Request $request) { $categoryId = $request->categoryId; $providerId = $request->providerId; $Model = new Product(); $total = $Model->getAll()->count(); $Model = $Model->getAll()->orderBy('id', 'DESC'); if ($categoryId) { $total = $Model->where('category_id', $categoryId)->count(); } if ($providerId) { $total = $Model->where('provider_id', $providerId)->count(); } $datas = $this->paging($Model, $request); $arrTotal = ['total' => $total]; return $this->ResponseData($datas, $arrTotal); }
public function actionIndex() { $products = Product::getAll(); return $this->render('index', ['products' => $products]); }
public function actionAll() { $modelProduct = new Product(); $allProducts = $modelProduct->getAll(); return $this->render('all', ['allProducts' => $allProducts]); }