We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 60715c0 + 0b22814 commit 4f653eeCopy full SHA for 4f653ee
src/WinkPost.php
@@ -169,6 +169,20 @@ public function scopeAfterPublishDate($query, $date)
169
return $query->where('publish_date', '>', $date);
170
}
171
172
+ /**
173
+ * Scope a query to only include posts that have a specific tag (by slug).
174
+ *
175
+ * @param \Illuminate\Database\Eloquent\Builder $query
176
+ * @param string $slug
177
+ * @return \Illuminate\Database\Eloquent\Builder
178
+ */
179
+ public function scopeTag($query, string $slug)
180
+ {
181
+ return $query->whereHas('tags', function ($query) use ($slug) {
182
+ $query->where('slug', $slug);
183
+ });
184
+ }
185
+
186
/**
187
* Prepare a date for array / JSON serialization.
188
*
0 commit comments