1 | <?php |
||
8 | trait TaggableTrait |
||
9 | { |
||
10 | /** |
||
11 | * The Eloquent tags model name. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | protected static $tagsModel = Tag::class; |
||
16 | |||
17 | /** |
||
18 | * Returns the Eloquent tags model name. |
||
19 | * @return string |
||
20 | */ |
||
21 | public static function getTagsModel() |
||
25 | |||
26 | /** |
||
27 | * Sets the Eloquent tags model name. |
||
28 | * @param string $model |
||
29 | * @return void |
||
30 | */ |
||
31 | public static function setTagsModel($model) |
||
35 | |||
36 | /** |
||
37 | * Get all the entities with the given tag(s) |
||
38 | * Optionally specify the column on which |
||
39 | * to perform the search operation. |
||
40 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
41 | * @param string|array $tags |
||
42 | * @param string $type |
||
43 | * @return \Illuminate\Database\Eloquent\Builder |
||
44 | */ |
||
45 | public function scopeWhereTag(Builder $query, $tags, $type = 'slug') |
||
62 | |||
63 | /** |
||
64 | * Get all the entities with one of the given tag(s) |
||
65 | * Optionally specify the column on which |
||
66 | * to perform the search operation. |
||
67 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
68 | * @param string|array $tags |
||
69 | * @param string $type |
||
70 | * @return \Illuminate\Database\Eloquent\Builder |
||
71 | */ |
||
72 | public function scopeWithTag(Builder $query, $tags, $type = 'slug') |
||
85 | |||
86 | /** |
||
87 | * Returns the entity Eloquent tag model object. |
||
88 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
89 | */ |
||
90 | public function tags() |
||
94 | |||
95 | /** |
||
96 | * Creates a new model instance. |
||
97 | * @return \Illuminate\Database\Eloquent\Model |
||
98 | */ |
||
99 | public static function createTagsModel() |
||
103 | |||
104 | /** |
||
105 | * Returns all the tags under the entity namespace. |
||
106 | * @return \Illuminate\Database\Eloquent\Builder |
||
107 | */ |
||
108 | public static function allTags() |
||
114 | |||
115 | /** |
||
116 | * Attaches or detaches the given tags. |
||
117 | * @param string|array $tags |
||
118 | * @param string $type |
||
119 | * @return bool |
||
120 | */ |
||
121 | public function setTags($tags, $type = 'slug') |
||
142 | |||
143 | /** |
||
144 | * Attaches multiple tags to the entity. |
||
145 | * |
||
146 | * @param string|array $tags |
||
147 | * @return bool |
||
148 | */ |
||
149 | public function tag($tags) |
||
157 | |||
158 | /** |
||
159 | * Attaches the given tag to the entity. |
||
160 | * @param string $name |
||
161 | * @return void |
||
162 | */ |
||
163 | public function addTag($name) |
||
188 | |||
189 | /** |
||
190 | * {@inheritdoc} |
||
191 | */ |
||
192 | public function untag($tags = null) |
||
202 | |||
203 | /** |
||
204 | * Detaches the given tag from the entity. |
||
205 | * @param string $name |
||
206 | * @return void |
||
207 | */ |
||
208 | public function removeTag($name) |
||
222 | |||
223 | /** |
||
224 | * Returns the entity class name. |
||
225 | * |
||
226 | * @return string |
||
227 | */ |
||
228 | protected function getEntityClassName() |
||
236 | |||
237 | /** |
||
238 | * Generate the tag slug using the given name. |
||
239 | * @param string $name |
||
240 | * @return string |
||
241 | */ |
||
242 | protected function generateTagSlug($name) |
||
246 | } |
||
247 |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.