1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Agent |
4
|
|
|
* |
5
|
|
|
* @package LivePersonInc\LiveEngageLaravel\Models |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace LivePersonInc\LiveEngageLaravel\Models; |
9
|
|
|
|
10
|
|
|
use Carbon\Carbon; |
11
|
|
|
use Illuminate\Database\Eloquent\Model; |
12
|
|
|
use LivePersonInc\LiveEngageLaravel\Facades\LiveEngageLaravel as LiveEngage; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Agent class. |
16
|
|
|
* |
17
|
|
|
* @extends Model |
18
|
|
|
*/ |
19
|
|
|
class Agent extends Model |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* guarded |
23
|
|
|
* |
24
|
|
|
* (default value: []) |
25
|
|
|
* |
26
|
|
|
* @var mixed |
27
|
|
|
* @access protected |
28
|
|
|
*/ |
29
|
|
|
protected $guarded = []; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* userTypes |
33
|
|
|
* |
34
|
|
|
* @var mixed |
35
|
|
|
* @access protected |
36
|
|
|
*/ |
37
|
|
|
protected $userTypes = [ |
38
|
|
|
0 => 'System', |
39
|
|
|
1 => 'Human', |
40
|
|
|
2 => 'Bot' |
41
|
|
|
]; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* getUserTypeNameAttribute function. |
45
|
|
|
* |
46
|
|
|
* @access public |
47
|
|
|
* @return string |
48
|
|
|
* @codeCoverageIgnore |
49
|
|
|
*/ |
50
|
|
|
public function getUserTypeNameAttribute() |
51
|
|
|
{ |
52
|
|
|
$typeid = isset($this->attributes['userTypeId']) ? $this->attributes['userTypeId'] : $this->attributes['userType']; |
53
|
|
|
return $this->userTypes[$typeid]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* getLastUpdatedTimeAttribute function. |
58
|
|
|
* |
59
|
|
|
* @access public |
60
|
|
|
* @return \Carbon\Carbon |
61
|
|
|
* @codeCoverageIgnore |
62
|
|
|
*/ |
63
|
|
|
public function getLastUpdatedTimeAttribute() |
64
|
|
|
{ |
65
|
|
|
return new Carbon($this->attributes['lastUpdatedTime']); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* getCurrentStatusStartTimeAttribute function. |
70
|
|
|
* |
71
|
|
|
* @access public |
72
|
|
|
* @return \Carbon\Carbon |
73
|
|
|
* @codeCoverageIgnore |
74
|
|
|
*/ |
75
|
|
|
public function getCurrentStatusStartTimeAttribute() |
76
|
|
|
{ |
77
|
|
|
return new Carbon($this->attributes['currentStatusStartTime']); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* getCurrentStatusReasonStartTimeAttribute function. |
82
|
|
|
* |
83
|
|
|
* @access public |
84
|
|
|
* @return \Carbon\Carbon |
85
|
|
|
* @codeCoverageIgnore |
86
|
|
|
*/ |
87
|
|
|
public function getCurrentStatusReasonStartTimeAttribute() |
88
|
|
|
{ |
89
|
|
|
return new Carbon($this->attributes['currentStatusReasonStartTime']); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* getStatusMinutesAttribute function. |
94
|
|
|
* |
95
|
|
|
* @access public |
96
|
|
|
* @return float |
97
|
|
|
* @codeCoverageIgnore |
98
|
|
|
*/ |
99
|
|
|
public function getStatusMinutesAttribute() |
100
|
|
|
{ |
101
|
|
|
return ($this->attributes['currentStatusDuration'] / 1000) / 60; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* getAvatarAttribute function. |
106
|
|
|
* |
107
|
|
|
* @access public |
108
|
|
|
* @return string |
109
|
|
|
* @codeCoverageIgnore |
110
|
|
|
*/ |
111
|
|
|
public function getAvatarAttribute() |
112
|
|
|
{ |
113
|
|
|
return isset($this->attributes['pictureUrl']) ? $this->attributes['pictureUrl'] : null; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* getDetailsAttribute function. |
118
|
|
|
* |
119
|
|
|
* @access public |
120
|
|
|
* @return void |
121
|
|
|
*/ |
122
|
|
|
public function getDetailsAttribute() |
123
|
|
|
{ |
124
|
|
|
return \LiveEngage::getAgent($this->agentId); |
|
|
|
|
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
} |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.