CitysReply.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\citys\model;
  9. use think\Model;
  10. class CitysReply extends Model{
  11. protected $pk = 'id';
  12. protected $autoWriteTimestamp = true;
  13. //用户
  14. public function user(){
  15. return $this->hasOne('app\common\model\SystemUser','id','uid');
  16. }
  17. //用户
  18. public function info(){
  19. return $this->hasOne('citys','id','info_id');
  20. }
  21. //添加或编辑
  22. public static function postReply($param){
  23. $data['reply'] = $param['content'];
  24. $data['member_miniapp_id'] = $param['member_miniapp_id'];
  25. $data['uid'] = $param['uid'];
  26. $data['info_id'] = $param['info_id'];
  27. $data['create_time'] = time();
  28. $data['state'] = 0;
  29. return self::create($data);
  30. }
  31. /**
  32. * 锁定
  33. * @param integer $id
  34. */
  35. public static function lock(int $id){
  36. $result = self::get($id);
  37. $result->state = $result->state ? 0 : 1;
  38. return $result->save();;
  39. }
  40. }