GreenNews.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 内容管理
  7. */
  8. namespace app\green\model;
  9. use think\Model;
  10. class GreenNews extends Model{
  11. protected $autoWriteTimestamp = true;
  12. protected $createTime = false;
  13. //添加或编辑
  14. public static function edit($member_miniapp_id,$param){
  15. $data['types'] = trim($param['types']);
  16. $data['cate_id'] = trim($param['cate_id']);
  17. $data['desc'] = trim($param['desc']);
  18. $data['img'] = trim($param['img']);
  19. $data['title'] = trim($param['title']);
  20. $data['cate_name'] = trim($param['cate_name']);
  21. $data['content'] = trim($param['content']);
  22. $data['update_time'] = time();
  23. if(isset($param['id'])){
  24. $condition['id'] = $param['id'];
  25. $condition['member_miniapp_id'] = $member_miniapp_id;
  26. return self::where($condition)->update($data);
  27. }else{
  28. $data['member_miniapp_id'] = $member_miniapp_id;
  29. return self::create($data);
  30. }
  31. }
  32. }