/** * 添加网址分类 * * @param Request $request * @author yangyifan <*****@*****.**> */ public function postSiteCategory(SearchCatRequest $request) { if (Session::get('admin_info.id') > 0) { //写入数据 $affected_number = SiteCatModel::create($request->all()); return $affected_number->id > 0 ? $this->response(200, trans('response.add_success'), [], false, url('admin/site/index')) : $this->response(400, trans('response.add_error'), [], false); } }
/** * 处理新增文章分类 * * @author yangyifan <*****@*****.**> */ public function postAdd(SiteCatRequest $request) { $affected_number = SiteCatModel::create($request->all()); return $affected_number->id > 0 ? $this->response(200, trans('response.add_success'), [], true, url('admin/site-cat/index')) : $this->response(400, trans('response.add_error'), [], true, url('admin/article-cat/index')); }
/** * 增加文章 * * @author yangyifan <*****@*****.**> */ public function getAdd() { return $this->html_builder->builderTitle('增加网址')->builderFormSchema('site_name', '网址名称')->builderFormSchema('name', '网址别名')->builderFormSchema('site_cat_id', '所属分类', 'select', $default = '', $notice = '', $class = '', $rule = '*', $err_message = '', SiteCatModel::getAllForSchemaOption('cat_name'), 'cat_name')->builderFormSchema('site_url', '网址url', $type = 'text', $default = '', $notice = '', $class = '', $rule = 'url', $err_message = '', $option = '', $option_value_schema = '')->builderFormSchema('icon', '网址icon', 'image')->builderFormSchema('thumb_small', '缩略图【小图】', 'image')->builderFormSchema('thumb_medium', '缩略图【中图】', 'image')->builderFormSchema('thumb_logo', '网址logo', 'image')->builderFormSchema('sort', '排序', 'text', 255)->builderFormSchema('status', '状态', 'radio', '', '', '', '', '', [1 => '开启', '2' => '关闭'], '1')->builderFormSchema('view', '点击量', 'text', mt_rand(100, 200))->builderConfirmBotton('确认', url('admin/site/add'), 'btn btn-success')->builderAdd(); }
/** * 删除数据 * * @param $id * @throws \Exception * @author yangyifan <*****@*****.**> */ public function getDelete($id) { SiteCatModel::del($id) > 0 ? $this->response(200, trans('response.delete_success'), [], false, url('admin/news/index')) : $this->response(400, trans('response.delete_error'), [], false); }