/** * 保存数据 * @return \Illuminate\View\View * @throws DeepInHtmlException */ public function save() { $name = \Input::get("categoryname"); $enName = \Input::get("encategoryname"); if (empty($name) || empty($enName)) { throw new DeepInHtmlException("参数不能为空~!"); } $category = new ShopTopicCategory(); $category->categoryName($name); $category->enCategoryName($enName); if ($category->save() == false) { throw new DeepInHtmlException("保存数据失败~!"); } return $this->success("保存数据成功~!"); }
/** * 根据id找分类对象 * @param $id * @return ShopTopicCategory * @throws DeepInException */ protected function find($id) { $category = ShopTopicCategory::find($id); if ($category instanceof ShopTopicCategory) { return $category; } throw new DeepInException("找不到专题分类id为" . $id . "的数据~!"); }
/** * 新增专题页面 * @return \Illuminate\View\View */ public function add() { $category = ShopTopicCategory::all(); return view("admin.topic.add", array("category" => $category)); }
/** *根据选择项显示不同的下拉选择项目 * @return \Illuminate\Http\JsonResponse * @throws DeepInException */ public function getItemIds() { $type = intval(\Input::get("type")); $checkVal = intval(\Input::get("check_val")); //对应的类型(1栏目 2专题类别 3slider) $data = array(); $data[1] = function () { //栏目 return ShopColumn::all(); }; $data[2] = function () { return ShopTopicCategory::all(); }; $data[3] = function () { return ShopSliderCategory::all(); }; if (!isset($data[$type])) { throw new DeepInException("错误的type" . $type); } return $this->successJSON(array("option" => $this->formatToOption($data[$type](), $checkVal))); }