1 | <?php |
||
9 | class Purchase extends Eloquent\Model |
||
10 | { |
||
11 | const UPCOMING = 'upcoming'; |
||
12 | const DELIVERED = 'delivered'; |
||
13 | const COMPLETED = 'completed'; |
||
14 | |||
15 | /** |
||
16 | * We do not want any timestamps. |
||
17 | * |
||
18 | * @var bool |
||
19 | */ |
||
20 | public $timestamps = false; |
||
21 | |||
22 | /** |
||
23 | * The attributes that are not mass assignable. |
||
24 | * |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $guarded = []; |
||
28 | |||
29 | /** |
||
30 | * Date mutators. |
||
31 | * |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $dates = ['date_purchased', 'delivery_date']; |
||
35 | |||
36 | /** |
||
37 | * Default date format. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $dateFormat = 'Y-m-d'; |
||
42 | |||
43 | /** |
||
44 | * Delivered Scope. |
||
45 | * |
||
46 | * @param $query |
||
47 | * |
||
48 | * @return Eloquent\Builder |
||
49 | */ |
||
50 | public function scopeDelivered($query) |
||
54 | |||
55 | /** |
||
56 | * Stored Scope. |
||
57 | * |
||
58 | * @param $query |
||
59 | * |
||
60 | * @return Eloquent\Builder |
||
61 | */ |
||
62 | public function scopeStored($query) |
||
66 | |||
67 | /** |
||
68 | * Pending Storage scope. |
||
69 | * |
||
70 | * @param $query |
||
71 | * |
||
72 | * @return Eloquent\Builder |
||
73 | */ |
||
74 | public function scopePendingStorage($query) |
||
78 | |||
79 | /** |
||
80 | * Get status attribute. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | 2 | public function getStatusAttribute() |
|
95 | |||
96 | /** |
||
97 | * Has Guitars Pending Storage? |
||
98 | * |
||
99 | * @return bool |
||
100 | */ |
||
101 | public function isPendingStorage() |
||
105 | |||
106 | /** |
||
107 | * Guitars bought. |
||
108 | * |
||
109 | * @return Eloquent\Relations\HasMany |
||
110 | */ |
||
111 | public function guitars() |
||
115 | |||
116 | /** |
||
117 | * Pending Storage attribute. |
||
118 | * |
||
119 | * @return int |
||
120 | */ |
||
121 | public function getPendingStorageAttribute() |
||
125 | |||
126 | /** |
||
127 | * Whether the purchase has arrived. |
||
128 | * |
||
129 | * @return bool |
||
130 | */ |
||
131 | 1 | public function hasArrived() |
|
132 | { |
||
133 | 1 | return $this->isStatus(self::DELIVERED); |
|
134 | } |
||
135 | |||
136 | /** |
||
137 | * Verify the status. |
||
138 | * |
||
139 | * @param $status |
||
140 | * |
||
141 | * @return bool |
||
142 | */ |
||
143 | 1 | public function isStatus($status) |
|
144 | { |
||
145 | 1 | return $this->status == $status; |
|
146 | } |
||
147 | |||
148 | /** |
||
149 | * Supplier from which guitars were bought. |
||
150 | * |
||
151 | * @return Eloquent\Relations\BelongsTo |
||
152 | */ |
||
153 | public function supplier() |
||
157 | |||
158 | /** |
||
159 | * Make of the guitars. |
||
160 | * |
||
161 | * @return Eloquent\Relations\BelongsTo |
||
162 | */ |
||
163 | 1 | public function make() |
|
167 | |||
168 | /** |
||
169 | * Notifications about the purchase. |
||
170 | * |
||
171 | * @return Eloquent\Relations\MorphMany |
||
172 | */ |
||
173 | public function notifications() |
||
177 | |||
178 | /** |
||
179 | * Create a new notification. |
||
180 | * |
||
181 | * @param Notification $notification |
||
182 | * |
||
183 | * @return Notification |
||
184 | */ |
||
185 | public function makeNotification(Notification $notification) |
||
189 | } |
||
190 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.