Example #1
0
 public static function getMenu()
 {
     $categoryCls = new CategoryModel();
     $arrParentList = $categoryCls->getParentList();
     $arrChirdList = $categoryCls->getChildList();
     return view('Frontend.menu', ['arrParentList' => $arrParentList, 'arrChirdList' => $arrChirdList]);
 }
Example #2
0
 public static function getIndex()
 {
     $categoryCls = new CategoryModel();
     $productCls = new ProductModel();
     $customersModel = new CustomersModel();
     // check if user login later register
     if (Session::has('register_flag')) {
         $data = $customersModel->getUserByEmail(Session::get('customer_email'));
         Mail::send('Frontend.email.register', $data, function ($message) use($data) {
             $message->to($data['customer_email'], $data['customer_name'])->subject('Cường thuỷ - Xác nhận đăng kí!');
         });
         Session::forget('register_flag');
     }
     $arrParentList = $categoryCls->getParentList();
     $arrChirdList = $categoryCls->getChildList();
     foreach ($arrParentList as $key => $val) {
         $whereArr = array('OR' => array('categories.id' => $key, 'categories.category_parent' => $key));
         $joinsArr = array(array('table' => 'categories', 'type' => 'INNER', 'conditions' => 'products.product_category = categories.id'));
         $limitArr = array(self::$PRODUCT_MAX);
         $arrProductList[$key] = $productCls->getProductList($whereArr, $limitArr, $joinsArr);
     }
     $arrProductNew = $productCls->getProductNew(array(), array(self::$PRODUCT_MAX));
     BaseController::$title = 'Uy tín, chất lượng, giá rẻ cho mọi nhà ';
     return view('Frontend.index', ['arrParentList' => $arrParentList, 'arrChirdList' => $arrChirdList, 'arrProductList' => $arrProductList, 'arrProductNew' => $arrProductNew]);
 }
Example #3
0
 public static function getIndex()
 {
     $productCls = new ProductModel();
     $categoryCls = new CategoryModel();
     $whereArr = array();
     $joinsArr = array();
     $categoryId = '';
     if (Input::has('category_id')) {
         $categoryId = Input::get('category_id');
         $joinsArr = array(array('table' => 'categories', 'type' => 'RIGHT', 'conditions' => 'products.product_category = categories.id'));
         if ($categoryId > 0) {
             $whereArr['OR'] = array('categories.id' => $categoryId, 'categories.category_parent' => $categoryId);
         } else {
             $whereArr['OR'] = array('categories.id' => $categoryId);
         }
     } else {
         $whereArr['product_sell_status LIKE'] = "%1%";
     }
     $searchKey = '';
     $searchValue = '';
     if (Input::has('search_key')) {
         $searchKey = Input::get('search_key');
         switch ($searchKey) {
             case 'newer':
                 $whereArr['product_sell_status LIKE'] = "%1%";
                 break;
             case 'hot':
                 $whereArr['product_sell_status LIKE'] = "%3%";
                 break;
             case 'sell':
                 $whereArr['product_sell_status LIKE'] = "%2%";
                 break;
             default:
                 if (Input::has('search_value')) {
                     $searchValue = Input::get('search_value');
                     $whereArr[$searchKey . ' LIKE'] = "%" . $searchValue . "%";
                 }
                 break;
         }
     }
     if (Input::has('page')) {
         $page = Input::get('page');
     } else {
         $page = 1;
     }
     $totalRecord = $productCls->getCountResult($whereArr, $joinsArr);
     $maxRec = self::$PRODUCT_MAX;
     $offset = ($page - 1) * $maxRec;
     $lastPage = ceil($totalRecord / $maxRec);
     $currentPage = $page;
     $previousPage = $page > 1 ? $page - 1 : 1;
     $nextPage = $page < $lastPage ? $page + 1 : $lastPage;
     $limitArr = array($offset, $maxRec);
     $arrProductList = $productCls->getProductList($whereArr, $limitArr, $joinsArr);
     // get category name
     $categories = $categoryCls->getCategoryNamebyId($categoryId);
     BaseController::$title = 'Danh sách sản phẩm';
     return view('Frontend.list', ['arrProductList' => $arrProductList, 'currentPage' => $currentPage, 'lastPage' => $lastPage, 'previousPage' => $previousPage, 'nextPage' => $nextPage, 'categoryId' => $categoryId, 'categories' => $categories, 'search_key' => $searchKey, 'search_value' => $searchValue]);
 }
 public static function getList()
 {
     $model = new CategoryModel();
     $categories = $model->getData();
     return view('Frontend.category_list', compact('categories'));
 }