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