title='分类管理'; DataClassification::mQuery() ->show(1) ->like('name') ->order('id','desc') ->layTable(); } /** * 分类编辑 * @auth true * @menu true */ public function class_edit(){ DataClassification::mForm('class_form'); } /** * 分类添加 * @auth true * @menu true */ public function class_add(){ DataClassification::mForm('class_form'); } /** * 分类删除 * @auth true * @menu true */ public function class_del($id){ DataClassification::whereIn('id',$id)->save([ 'is_del'=>0, ]); $this->success('删除成功'); } /** * 百知文库申请管理 * @auth true * @menu true */ public function index(){ $this->title='百知文库申请列表'; $name=input('name'); DataBestKnowledge::mQuery() ->when($name,function (Query $query) use ($name) { $query->hasWhere('user',function (Query $query) use ($name) { $query->whereLike('nickname',"%{$name}%"); }); }) ->with(['user','classTo']) ->where('type',2) ->where('is_del',1) ->order('id','desc') ->layTable(); } /** * 百知文库申请审核 * @auth true * @menu true */ public function audit($id){ $this->title='百知文库申请审核'; $row=DataBestKnowledge::mk()->findOrFail($id); if($this->request->isGet()){ $this->assign('row',$row); $this->fetch(); }else{ if($row['audit']>1){ $this->error('该记录已审核'); } $data=$this->_vali([ 'audit.require'=>'结果必须', 'audit.in:2,3'=>'结果有误', 'why.requireIf:audit,3'=>'原因必须', 'why.max:200'=>'原因有误', ]); $row['audit']=$data['audit']; $row['why']=$data['why']??''; $row['audit_at']=Carbon::now(); $row->save(); $this->success('审核成功'); } } /** * 百知文库申请管理 * @auth true * @menu true */ public function index2(){ $this->title='百知文库列表'; $name=input('name'); DataBestKnowledge::mQuery() ->when($name,function (Query $query) use ($name) { $query->hasWhere('user',function (Query $query) use ($name) { $query->whereLike('nickname',"%{$name}%"); }); }) ->with(['user','classTo']) ->where('type',1) ->where('is_del',1) ->order('id','desc') ->layTable(); } /** * 百知文库添加 * @auth true * @menu true */ public function add(){ $this->assign('category',DataClassification::show(1)->select()); DataBestKnowledge::mForm('form'); } /** * 百知文库编辑 * @auth true * @menu true */ public function edit(){ $this->assign('category',DataClassification::show(1)->select()); DataBestKnowledge::mForm('form'); } public function _form_filter($vo){ if ($this->request->isGet()) { if (isset($vo['id'])){ if (isset($vo['imgs'])){ $vo['imgs']= implode('|',explode(',',implode(',',$vo['imgs']))); } $this->assign('vo',$vo); $this->fetch('form'); } }elseif ($this->request->isPost()){ $vo['imgs'] = implode(',',explode('|',$vo['imgs'])); $vo['audit'] =2; isset($vo['id']) ? DataBestKnowledge::mk()->where('id',$vo['id'])->update($vo) : DataBestKnowledge::mk()->insert($vo); $this->success('数据更新成功'); } } /** * 删除 * @auth true * @menu true */ public function del($id){ DataBestKnowledge::whereIn('id',$id)->save([ 'is_del'=>0, ]); $this->success('删除成功'); } }