Пример #1
0
 /**
  * 增加分类的时候的表单验证
  *
  * @access public
  */
 public function add(CategorySave $data)
 {
     $rules = array('category_name' => 'required', 'category_pid' => 'required|numeric', 'category_sort' => 'required|numeric');
     $messages = array('category_name.required' => Lang::get('shopcategory.category_name_empty'), 'category_pid.required' => Lang::get('shopcategory.category_pid_empty'), 'category_pid.numeric' => Lang::get('common.illegal_operation'), 'category_sort.required' => Lang::get('shopcategory.category_sort_empty'), 'category_sort.numeric' => Lang::get('common.category_sort_numeric'));
     $validator = Validator::make($data->toArray(), $rules, $messages);
     if ($validator->fails()) {
         $this->errorMsg = $validator->messages()->first();
         return false;
     }
     return true;
 }
Пример #2
0
 /**
  * 编辑入库
  *
  * @access private
  */
 private function editShopCategory()
 {
     $params = new CategorySave();
     $manager = new ProductCategoryProcess();
     $httpReferer = Session::getOldInput('http_referer');
     $data = (array) Request::input('data');
     $data['update_time'] = time();
     $params->setAttributes($data);
     if ($manager->editShopCategory($params) !== false) {
         $backUrl = !empty($httpReferer) ? $httpReferer : route('shop.category.index');
         return Js::locate($backUrl, 'parent');
     }
     return Js::error($manager->getErrorMessage());
 }