Example #1
0
 public static function _validation_valid_category($val)
 {
     if (self::_empty($val)) {
         return true;
     }
     return Model_Base_Category::valid_field('id', $val);
 }
Example #2
0
 public function post_list()
 {
     $page = (int) Input::post('page') !== 0 ? (int) Input::post('page') : 1;
     $category_id = Input::post('category_id');
     $type = !empty($category_id) && Model_Base_Category::valid_field('id', $category_id) ? true : false;
     $total = $type ? Model_Base_Product::admin_count_by_category($category_id) : Model_Base_Product::count_all();
     $limit = _DEFAULT_LIMIT_;
     $offset = $page * $limit - $limit < $total ? $page * $limit - $limit : _DEFAULT_OFFSET_;
     $this->data['product'] = $type ? Model_Base_Product::admin_get_by_category($category_id, $offset, $limit) : Model_Base_Product::get_all($offset, $limit);
     $this->data['success'] = true;
     return $this->response($this->data);
 }