1 | <?php |
||
16 | class Product extends Repository |
||
17 | { |
||
18 | use ActivateableTrait, Presenterable, HasMeta, HasImages, Taggable; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $table = 'products'; |
||
24 | |||
25 | /** |
||
26 | * @var ProductPresenter |
||
27 | */ |
||
28 | protected $presenter = ProductPresenter::class; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $fillable = [ |
||
34 | 'sub_category_id', |
||
35 | 'lot_id', |
||
36 | 'name', |
||
37 | 'featured', |
||
38 | 'price', |
||
39 | 'old_price', |
||
40 | 'sale', |
||
41 | 'count', |
||
42 | 'active', |
||
43 | 'description', |
||
44 | 'uniqid' |
||
45 | ]; |
||
46 | |||
47 | /** |
||
48 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
49 | */ |
||
50 | public function colors() |
||
54 | |||
55 | /** |
||
56 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
57 | */ |
||
58 | public function lot() |
||
62 | |||
63 | /** |
||
64 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
65 | */ |
||
66 | public function involved() |
||
70 | |||
71 | /** |
||
72 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
73 | */ |
||
74 | public function improvedSpecs() |
||
78 | /** |
||
79 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
80 | */ |
||
81 | public function specPrice() |
||
85 | /** |
||
86 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
87 | */ |
||
88 | public function subcategory() |
||
92 | |||
93 | /** |
||
94 | * Drafted products scope. |
||
95 | * |
||
96 | * @param $query |
||
97 | * @return \Illuminate\Database\Query\Builder |
||
98 | */ |
||
99 | public function scopeDrafted($query) |
||
103 | |||
104 | /** |
||
105 | * Published products scope. |
||
106 | * |
||
107 | * @param $query |
||
108 | * @return \Illuminate\Database\Query\Builder |
||
109 | */ |
||
110 | public function scopePublished($query) |
||
114 | |||
115 | /** |
||
116 | * Completed products scope. |
||
117 | * |
||
118 | * @param $query |
||
119 | * @return \Illuminate\Database\Query\Builder |
||
120 | */ |
||
121 | public function scopeCompleted($query) |
||
125 | |||
126 | /** |
||
127 | * Featured products scope. |
||
128 | * |
||
129 | * @param $query |
||
130 | * @return mixed |
||
131 | */ |
||
132 | public function scopeFeatured($query) |
||
136 | |||
137 | /** |
||
138 | * Get a collection of all Tags a Model has. |
||
139 | * |
||
140 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
141 | */ |
||
142 | public function tags() |
||
147 | |||
148 | /** |
||
149 | * Scope for a Model that has all of the given tags. |
||
150 | * |
||
151 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
152 | * @param array|string $tags |
||
153 | * |
||
154 | * @return \Illuminate\Database\Eloquent\Builder |
||
155 | */ |
||
156 | public function scopeWithAllTags(Builder $query, $tags) |
||
164 | } |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: