29 lines
612 B
PHP
29 lines
612 B
PHP
|
|
<?php
|
||
|
|
namespace app\common\model;
|
||
|
|
|
||
|
|
use think\Model;
|
||
|
|
use app\common\model\User ;
|
||
|
|
|
||
|
|
class FriendRequests extends Model
|
||
|
|
{
|
||
|
|
protected $name = 'friend_requests';
|
||
|
|
// 自动写入时间戳字段
|
||
|
|
protected $autoWriteTimestamp = 'int';
|
||
|
|
// 定义时间戳字段名
|
||
|
|
protected $createTime = 'createtime';
|
||
|
|
protected $updateTime = 'updatetime';
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
public function fromUser()
|
||
|
|
{
|
||
|
|
return $this->belongsTo('User', 'from_user_id', 'id');
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public static function getNotification($to_user_id)
|
||
|
|
{
|
||
|
|
|
||
|
|
return self::where(['to_user_id'=>$to_user_id,'status'=>0])->count();
|
||
|
|
}
|
||
|
|
}
|