IntermediaryModel.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: pl125 <xskjs888@163.com>
// +----------------------------------------------------------------------
namespace api\portal\model;
use api\common\model\CommonModel;
class IntermediaryModel extends CommonModel
{
//可查询字段
// protected $visible = [
// 'articles.id', 'user_nickname', 'avatar', 'signature','user'
// ];
//模型关联方法
protected $relationFilter = ['user'];
/**
* 基础查询
*/
protected function base($query)
{
$query->alias('user')->where('user.user_status', 1);
}
/**
* more 自动转化
* @param $value
* @return array
*/
public function getAvatarAttr($value)
{
$value = !empty($value) ? cmf_get_image_url($value) : $value;
return $value;
}
/**
* 关联 user表
* @return $this
*/
public function user()
{
return $this->belongsTo('UserModel', 'user_id')->setEagerlyType(1);
}
}