-
Notifications
You must be signed in to change notification settings - Fork 20
/
BindBox.php
60 lines (51 loc) · 1.12 KB
/
BindBox.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
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use App\{
Address,
Currency,
UsersInsurance,
InsuranceType,
InsuranceClaimApply,
Users,
UserCashInfo,
UserReal,
UsersWallet,
BindBoxOrder,
BindBoxQuotationLog,
BindBoxCollect
};
class BindBox extends Model
{
protected $table = 'bind_box';
public $timestamps = false;
protected $appends = [
'head_portrait',
'author_name',
'currency_name',
];
public function currency()
{
return $this->belongsTo(Currency::class);
}
public function getCurrencyNameAttribute()
{
return $this->currency()->value('name');
}
public function getHeadPortraitAttribute()
{
$user = Users::find($this->attributes['author']);
if (!empty($user)) {
return $user->head_portrait;
}
return '';
}
public function getAuthorNameAttribute()
{
$user = Users::find($this->attributes['author']);
if (!empty($user)) {
return $user->nickname;
}
return '';
}
}