1 | <?php namespace Arcanedev\LaravelTracker\Models; |
||
33 | class Session extends AbstractModel implements SessionContract |
||
34 | { |
||
35 | /* ------------------------------------------------------------------------------------------------ |
||
36 | | Traits |
||
37 | | ------------------------------------------------------------------------------------------------ |
||
38 | */ |
||
39 | use Presenters\SessionPresenter; |
||
40 | |||
41 | /* ------------------------------------------------------------------------------------------------ |
||
42 | | Properties |
||
43 | | ------------------------------------------------------------------------------------------------ |
||
44 | */ |
||
45 | /** |
||
46 | * The table associated with the model. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $table = 'sessions'; |
||
51 | |||
52 | /** |
||
53 | * The attributes that are mass assignable. |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $fillable = [ |
||
58 | 'uuid', |
||
59 | 'user_id', |
||
60 | 'device_id', |
||
61 | 'language_id', |
||
62 | 'agent_id', |
||
63 | 'client_ip', |
||
64 | 'cookie_id', |
||
65 | 'referer_id', |
||
66 | 'geoip_id', |
||
67 | 'is_robot', |
||
68 | ]; |
||
69 | |||
70 | /** |
||
71 | * The attributes that should be cast to native types. |
||
72 | * |
||
73 | * @var array |
||
74 | */ |
||
75 | protected $casts = [ |
||
76 | 'user_id' => 'integer', |
||
77 | 'device_id' => 'integer', |
||
78 | 'language_id' => 'integer', |
||
79 | 'agent_id' => 'integer', |
||
80 | 'cookie_id' => 'integer', |
||
81 | 'referer_id' => 'integer', |
||
82 | 'geoip_id' => 'integer', |
||
83 | 'is_robot' => 'boolean', |
||
84 | ]; |
||
85 | |||
86 | /* ------------------------------------------------------------------------------------------------ |
||
87 | | Relationships |
||
88 | | ------------------------------------------------------------------------------------------------ |
||
89 | */ |
||
90 | /** |
||
91 | * User relationship. |
||
92 | * |
||
93 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
94 | */ |
||
95 | public function user() |
||
101 | |||
102 | /** |
||
103 | * Device relationship. |
||
104 | * |
||
105 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
106 | */ |
||
107 | public function device() |
||
113 | |||
114 | /** |
||
115 | * Agent relationship. |
||
116 | * |
||
117 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
118 | */ |
||
119 | public function agent() |
||
125 | |||
126 | /** |
||
127 | * Referer relationship. |
||
128 | * |
||
129 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
130 | */ |
||
131 | public function referer() |
||
137 | |||
138 | /** |
||
139 | * Cookie relationship. |
||
140 | * |
||
141 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
142 | */ |
||
143 | public function cookie() |
||
149 | |||
150 | /** |
||
151 | * GeoIp relationship. |
||
152 | * |
||
153 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
154 | */ |
||
155 | public function geoip() |
||
161 | |||
162 | /** |
||
163 | * Language relationship. |
||
164 | * |
||
165 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
166 | */ |
||
167 | public function language() |
||
173 | |||
174 | /** |
||
175 | * Session activities relationship. |
||
176 | * |
||
177 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
178 | */ |
||
179 | public function activities() |
||
185 | |||
186 | /* ------------------------------------------------------------------------------------------------ |
||
187 | | Check Functions |
||
188 | | ------------------------------------------------------------------------------------------------ |
||
189 | */ |
||
190 | /** |
||
191 | * Check if the user exists. |
||
192 | * |
||
193 | * @return bool |
||
194 | */ |
||
195 | public function hasUser() |
||
199 | |||
200 | /** |
||
201 | * Check if the geoip exists. |
||
202 | * |
||
203 | * @return bool |
||
204 | */ |
||
205 | public function hasGeoip() |
||
209 | |||
210 | /** |
||
211 | * Check if the user agent exists. |
||
212 | * |
||
213 | * @return bool |
||
214 | */ |
||
215 | public function hasUserAgent() |
||
219 | |||
220 | /** |
||
221 | * Check if the device exists. |
||
222 | * |
||
223 | * @return bool |
||
224 | */ |
||
225 | public function hasDevice() |
||
229 | |||
230 | /** |
||
231 | * Check if the referer exists. |
||
232 | * |
||
233 | * @return bool |
||
234 | */ |
||
235 | public function hasReferer() |
||
239 | |||
240 | /** |
||
241 | * Check if the cookie exists. |
||
242 | * |
||
243 | * @return bool |
||
244 | */ |
||
245 | public function hasCookie() |
||
249 | } |
||
250 |