1 | <?php |
||
42 | class Purchase extends Eloquent\Model |
||
43 | { |
||
44 | const UPCOMING = 'upcoming'; |
||
45 | const DELIVERED = 'delivered'; |
||
46 | const COMPLETED = 'completed'; |
||
47 | |||
48 | use Eloquent\SoftDeletes; |
||
49 | |||
50 | /** |
||
51 | * We do not want any timestamps. |
||
52 | * |
||
53 | * @var bool |
||
54 | */ |
||
55 | public $timestamps = false; |
||
56 | |||
57 | /** |
||
58 | * The attributes that are not mass assignable. |
||
59 | * |
||
60 | * @var array |
||
61 | */ |
||
62 | protected $guarded = []; |
||
63 | |||
64 | /** |
||
65 | * Date mutators. |
||
66 | * |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $dates = ['date_purchased', 'delivery_date', 'deleted_at']; |
||
70 | |||
71 | /** |
||
72 | * Default date format. |
||
73 | * |
||
74 | * @var string |
||
75 | */ |
||
76 | protected $dateFormat = 'Y-m-d'; |
||
77 | |||
78 | 8 | public static function boot() |
|
87 | |||
88 | /** |
||
89 | * Delivered Scope. |
||
90 | * |
||
91 | * @param $query |
||
92 | * |
||
93 | * @return Eloquent\Builder |
||
94 | */ |
||
95 | public function scopeDelivered($query) |
||
99 | |||
100 | /** |
||
101 | * Stored Scope. |
||
102 | * |
||
103 | * @param $query |
||
104 | * |
||
105 | * @return Eloquent\Builder |
||
106 | */ |
||
107 | public function scopeStored($query) |
||
111 | |||
112 | /** |
||
113 | * Pending Storage scope. |
||
114 | * |
||
115 | * @param $query |
||
116 | * |
||
117 | * @return Eloquent\Builder |
||
118 | */ |
||
119 | public function scopePendingStorage($query) |
||
123 | |||
124 | /** |
||
125 | * Get status attribute. |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | public function getStatusAttribute() |
||
140 | |||
141 | /** |
||
142 | * Has Guitars Pending Storage? |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | public function isPendingStorage() |
||
150 | |||
151 | /** |
||
152 | * Guitars bought. |
||
153 | * |
||
154 | * @return Eloquent\Relations\HasMany |
||
155 | */ |
||
156 | public function guitars() |
||
160 | |||
161 | /** |
||
162 | * Storage attribute. |
||
163 | * |
||
164 | * @return int |
||
165 | */ |
||
166 | public function getStoredAttribute() |
||
170 | |||
171 | /** |
||
172 | * Pending Storage attribute. |
||
173 | * |
||
174 | * @return int |
||
175 | */ |
||
176 | public function getPendingStorageAttribute() |
||
180 | |||
181 | /** |
||
182 | * Number of Guitars Sold. |
||
183 | * |
||
184 | * @return int |
||
185 | */ |
||
186 | public function getSoldAttribute() |
||
190 | |||
191 | /** |
||
192 | * Whether the purchase has arrived. |
||
193 | * |
||
194 | * @return bool |
||
195 | */ |
||
196 | public function hasArrived() |
||
200 | |||
201 | /** |
||
202 | * Verify the status. |
||
203 | * |
||
204 | * @param $status |
||
205 | * |
||
206 | * @return bool |
||
207 | */ |
||
208 | public function isStatus($status) |
||
212 | |||
213 | /** |
||
214 | * Supplier from which guitars were bought. |
||
215 | * |
||
216 | * @return Eloquent\Relations\BelongsTo |
||
217 | */ |
||
218 | public function supplier() |
||
222 | |||
223 | /** |
||
224 | * Make of the guitars. |
||
225 | * |
||
226 | * @return Eloquent\Relations\BelongsTo |
||
227 | */ |
||
228 | public function make() |
||
232 | |||
233 | /** |
||
234 | * Notifications about the purchase. |
||
235 | * |
||
236 | * @return Eloquent\Relations\MorphMany |
||
237 | */ |
||
238 | public function notifications() |
||
242 | |||
243 | /** |
||
244 | * Create a new notification. |
||
245 | * @return Notification |
||
246 | */ |
||
247 | public function makeNotification() |
||
259 | } |
||
260 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.