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