1
|
|
|
<?php namespace Arcanedev\LaravelTracker\Models; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class Device |
5
|
|
|
* |
6
|
|
|
* @package Arcanedev\LaravelTracker\Models |
7
|
|
|
* @author ARCANEDEV <[email protected]> |
8
|
|
|
* |
9
|
|
|
* @property int id |
10
|
|
|
* @property string kind |
11
|
|
|
* @property string model |
12
|
|
|
* @property string platform |
13
|
|
|
* @property string platform_version |
14
|
|
|
* @property \Carbon\Carbon created_at |
15
|
|
|
* @property \Carbon\Carbon updated_at |
16
|
|
|
*/ |
17
|
|
|
class Device extends AbstractModel |
18
|
|
|
{ |
19
|
|
|
/* ------------------------------------------------------------------------------------------------ |
20
|
|
|
| Constants |
21
|
|
|
| ------------------------------------------------------------------------------------------------ |
22
|
|
|
*/ |
23
|
|
|
const KIND_COMPUTER = 'computer'; |
24
|
|
|
const KIND_PHONE = 'phone'; |
25
|
|
|
const KIND_TABLET = 'tablet'; |
26
|
|
|
const KIND_UNAVAILABLE = 'unavailable'; |
27
|
|
|
|
28
|
|
|
/* ------------------------------------------------------------------------------------------------ |
29
|
|
|
| Properties |
30
|
|
|
| ------------------------------------------------------------------------------------------------ |
31
|
|
|
*/ |
32
|
|
|
/** |
33
|
|
|
* The table associated with the model. |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
protected $table = 'devices'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The attributes that are mass assignable. |
41
|
|
|
* |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $fillable = [ |
45
|
|
|
'kind', |
46
|
|
|
'model', |
47
|
|
|
'platform', |
48
|
|
|
'platform_version', |
49
|
|
|
]; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* The attributes that should be cast to native types. |
53
|
|
|
* |
54
|
|
|
* @var array |
55
|
|
|
*/ |
56
|
|
|
protected $casts = [ |
57
|
|
|
'id' => 'integer', |
58
|
|
|
]; |
59
|
|
|
|
60
|
|
|
/* ------------------------------------------------------------------------------------------------ |
61
|
|
|
| Relationships |
62
|
|
|
| ------------------------------------------------------------------------------------------------ |
63
|
|
|
*/ |
64
|
|
|
|
65
|
|
|
/* ------------------------------------------------------------------------------------------------ |
66
|
|
|
| Check Functions |
67
|
|
|
| ------------------------------------------------------------------------------------------------ |
68
|
|
|
*/ |
69
|
|
|
/** |
70
|
|
|
* Is this a computer? |
71
|
|
|
* |
72
|
|
|
* @return bool |
73
|
|
|
*/ |
74
|
|
|
public function isComputer() |
75
|
|
|
{ |
76
|
|
|
return $this->kind == static::KIND_COMPUTER; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Is this a phone? |
81
|
|
|
* |
82
|
|
|
* @return bool |
83
|
|
|
*/ |
84
|
|
|
public function isPhone() |
85
|
|
|
{ |
86
|
|
|
return $this->kind == static::KIND_PHONE; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Is this a tablet? |
91
|
|
|
* |
92
|
|
|
* @return bool |
93
|
|
|
*/ |
94
|
|
|
public function isTablet() |
95
|
|
|
{ |
96
|
|
|
return $this->kind == static::KIND_TABLET; |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|