title='广告列表'; DataBestKnowledgeAd::mQuery()->layTable(); } /** * 新闻广告添加 * @auth true * @menu true */ public function ad_add(){ $this->ad_vali(); $this->assign('category',DataXwCategory::show()->select()); DataBestKnowledgeAd::mForm('ad_form'); } /** * 新闻广告编辑 * @auth true * @menu true */ public function ad_edit(){ $this->ad_vali(); $this->assign('category',DataXwCategory::show()->select()); DataBestKnowledgeAd::mForm('ad_form'); } protected function ad_vali(){ if($this->request->isPost()){ $this->_vali([ 'title.max:50'=>'标题过长', ]); } } /** * 新闻广告删除 * @auth true * @menu true */ public function ad_del(){ $ids=$this->request->post('id'); DataBestKnowledgeAd::whereIn('id',$ids)->select()->each(function ($d){$d->delete();}); $this->success('删除成功'); } /** * 新闻广告上下架 * @auth true * @menu true */ public function ad_state(){ DataBestKnowledgeAd::mSave([ 'status'=>$this->request->post('status'), ]); } /** * 表单结果处理 * @param boolean $state */ protected function _form_result(bool $state) { if ($state) { $this->success('保存成功!',in_array($this->request->action(),['add','edit','ad_add','ad_edit'])? 'javascript:history.back()':''); } } /** * 新闻报道设置 * @auth true * @menu true */ public function config(){ if($this->request->isGet()){ $this->title='间隔设置'; $this->assign('vo',sysconf('config_xw.')); $this->fetch(); }else{ $data=$this->_vali([ 'split_num2.require'=>'间隔数必须', 'user_avatar2.require'=>'头像数必须', 'user_avatar2.url'=>'头像链接有误', 'username2.require'=>'名称必须', 'split_num2.gt:0'=>'间隔数必须大于0', ]); sysconf('config_xw',$data); $this->success('保存成功'); } } }