public static function getCart() { $item = 0; $price = 0; if (Session::has('addcart')) { $cart = Session::get('addcart'); $item = 0; $price = 0; $mdPro = new Nproducts(); foreach (Session::get('addcart') as $key => $val) { $data = $mdPro->find($key); $price_convert = SiteHelpers::getPricePromotion($data); $price_item = $price_convert * $val; $price += $price_item; $item += $val; } } return $item . " item(s) - " . number_format($price, 0, ',', '.') . 'VNĐ'; }
public function search() { if (Input::get('search') == '') { return Redirect::to(''); } $s = Input::get('search'); $sortget = Input::get('sort') != '' ? Input::get('sort') : 'ProductID-desc'; list($sort, $order) = explode('-', $sortget); $filter = " AND status = 1 AND (ProductName LIKE '%" . $s . "%' OR Slug LIKE '%" . $s . "%' OR Content LIKE '%" . $s . "%' OR description LIKE '%" . $s . "%') AND lang = '{$this->lang}'"; $page = !is_null(Input::get('page') && Input::get('page') != '') ? Input::get('page') : 1; $params = array('page' => $page, 'limit' => !is_null(Input::get('numpage')) ? filter_var(Input::get('numpage'), FILTER_VALIDATE_INT) : $this->perpage, 'sort' => $sort, 'order' => $order, 'params' => $filter); $model = new Nproducts(); $results = $model->getRows($params); // Build pagination setting $page = $page >= 1 && filter_var($page, FILTER_VALIDATE_INT) !== false ? $page : 1; $pagination = Paginator::make($results['rows'], $results['total'], $params['limit']); $data['search'] = $s; $data['data'] = $results['rows']; $data['page'] = $page; $data['sort'] = $sortget; $data['numpage'] = $params['limit']; // Build Pagination $data['pagination'] = $pagination; // Build pager number and append current param GET $data['pager'] = $this->injectPaginate(); $this->data['pageTitle'] = 'Kết qua tìm kiếm từ khóa' . '"' . $s . '"'; $this->data['pageNote'] = 'Welcome To Our Site'; //$this->data['breadcrumb'] = 'inactive'; $page = 'pages.template.search'; $page = SiteHelpers::renderHtml($page); $this->layout->nest('content', $page, $data)->with('page', $this->data); }