NewsCate.php 971 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class NewsCate extends Base
  5. {
  6. protected $createTime = 'create_time';
  7. public function updates(){
  8. $data = request()->post();
  9. $data['org_id'] = cur_org_id();
  10. $result = validate('NewsCate')->check($data,[],'');
  11. if(true !== $result){
  12. $this->error = validate('NewsCate')->getError();
  13. return false;
  14. }
  15. $id = $data['id'];
  16. unset($data['id']);
  17. if($id > 0){
  18. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  19. }else{
  20. $data['create_time'] = date('Y-m-d H:i:s');
  21. $ret = $this->allowField(true)->save($data);
  22. }
  23. if(!$ret){
  24. $this->error = '操作失败';
  25. return false;
  26. }
  27. return true;
  28. }
  29. //app新闻列表
  30. public function getLists($orgId){
  31. $ret = $this->where('org_id',$orgId)->select();
  32. return $ret;
  33. }
  34. }