This repository has been archived by the owner on Apr 21, 2020. It is now read-only.
/
Fan.php
95 lines (86 loc) · 1.98 KB
/
Fan.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class Fan extends Model
{
/**
* 字段白名单.
*
* @var array
*/
protected $fillable = [
'account_id',
'groupid',
'openid',
'nickname',
'remark',
'sex',
'language',
'city',
'province',
'country',
'headimgurl',
'unionid',
'liveness',
'subscribe',
'subscribe_time',
'last_online_at',
'subscribe',
'tagid_list',
];
/**
* 用于表单验证时的字段名称提示.
*
* @var array
*/
public static $aliases = [
'account_id' => '公众号ID',
'groupid' => '粉丝组ID',
'openid' => 'OPENID',
'nickname' => '昵称',
'remark' => '备注',
'sex' => '性别',
'language' => '语言',
'city' => '城市',
'province' => '省份',
'country' => '国家',
'headimgurl' => '头像',
'unionid' => 'unionid',
'liveness' => '活跃度',
'subscribe_time' => '关注时间',
'last_online_at' => '最后上线时间',
'tagid_list' => '标签ID',
];
/**
* 附加字段.
*
* @var array
*/
protected $appends = ['location'];
protected $casts = [
'tagid_list' => 'array',
];
/**
* 返回性别.
*
* @return string
*/
public function getSexAttribute($sex)
{
return $sex == 1 ? '男' : '女';
}
/**
* 返回位置信息.
*
* @return string
*/
public function getLocationAttribute()
{
return $this->country.' '.$this->province.' '.$this->city;
}
public function setSubscribeTimeAttribute($value)
{
$this->attributes['subscribe_time'] = Carbon::createFromTimestamp($value);
}
}