From 11056417a1548056016bde85d3abeade1a73f311 Mon Sep 17 00:00:00 2001 From: Chris Weaver Date: Sat, 4 Jul 2020 08:39:12 -0400 Subject: [PATCH 1/2] Fixed a tiny typo --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 81bd90c4..ff4b0cc0 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,7 @@ php artisan wink:install php artisan storage:link ``` -**Configure the database connection** wink is going to be using in `config/wink.php`. The run: +**Configure the database connection** wink is going to be using in `config/wink.php`. Then run: ```sh php artisan wink:migrate From 0b22814cdb3ccefee5092684a2e416e36dfd73f9 Mon Sep 17 00:00:00 2001 From: Christopher Pitt Date: Sun, 12 Jul 2020 10:49:51 +0200 Subject: [PATCH 2/2] Allow filter posts by tag (slug) --- src/WinkPost.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/WinkPost.php b/src/WinkPost.php index f8689ab2..c5d32f25 100644 --- a/src/WinkPost.php +++ b/src/WinkPost.php @@ -169,6 +169,20 @@ public function scopeAfterPublishDate($query, $date) return $query->where('publish_date', '>', $date); } + /** + * Scope a query to only include posts that have a specific tag (by slug). + * + * @param \Illuminate\Database\Eloquent\Builder $query + * @param string $slug + * @return \Illuminate\Database\Eloquent\Builder + */ + public function scopeTag($query, string $slug) + { + return $query->whereHas('tags', function ($query) use ($slug) { + $query->where('slug', $slug); + }); + } + /** * Prepare a date for array / JSON serialization. *