NoticeCate.php 902 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class NoticeCate extends Base
  5. {
  6. public function updates(){
  7. $data = request()->post();
  8. $result = validate('NoticeCate')->check($data,[],'');
  9. if(true !== $result){
  10. $this->error = validate('NoticeCate')->getError();
  11. return false;
  12. }
  13. $id = $data['id'];
  14. unset($data['id']);
  15. if($id > 0){
  16. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  17. }else{
  18. $ret = $this->allowField(true)->save($data);
  19. }
  20. if(!$ret){
  21. $this->error = '操作失败';
  22. return false;
  23. }
  24. return true;
  25. }
  26. //分类列表
  27. public function lists(){
  28. $map[] = ['del','=',0];
  29. $map[] = ['enable','=',1];
  30. $ret = Db::name('notice_cate')->where($map)->select();
  31. return $ret;
  32. }
  33. }