1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- /**
- * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
- * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
- * @author pillar<ltmn@qq.com>
- * 评论管理
- */
- namespace app\allwin\model;
- use think\Model;
- class AllwinInfoReply extends Model{
- protected $pk = 'id';
- protected $autoWriteTimestamp = true;
- protected $datetime_format = 'Y-m-d H:i:s.u';
- //用户
- public function user(){
- return $this->hasOne('app\common\model\SystemUser','id','user_id');
- }
- //用户
- public function info(){
- return $this->hasOne('AllwinInfo','id','info_id');
- }
- //添加或编辑
- public static function postReply($param){
- $data['reply'] = trim($param['content']);
- $data['member_miniapp_id'] = (int)$param['member_miniapp_id'];
- $data['user_id'] = (int)$param['user_id'];
- $data['info_id'] = (int)$param['info_id'];
- $data['create_time'] = time();
- $data['state'] = 1;
- return self::insert($data);
- }
- /**
- * 锁定
- * @param integer $id
- */
- public static function lock(int $id){
- $result = self::get($id);
- $result->state = $result->state ? 0 : 1;
- return $result->save();;
- }
- }
|