From 0536d1073968d31fedc492ad9a8188198bd22554 Mon Sep 17 00:00:00 2001 From: Thomas Lang Date: Mon, 3 Jun 2019 12:00:23 +0200 Subject: [PATCH] if a tag does not exist, we dont want the query to crash (#61) * if a tag does not exist, we dont want the query to crash * incorrect solution Revert "if a tag does not exist, we dont want the query to crash" This reverts commit 6680e5a6e838ff9f53d338581d655671597b7bc5. * repaired getIdForSlug function to return int or null * changed where, removed isempty not needed --- extensions/tags/src/TagRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/tags/src/TagRepository.php b/extensions/tags/src/TagRepository.php index d2b0cbaf6..184081ce3 100644 --- a/extensions/tags/src/TagRepository.php +++ b/extensions/tags/src/TagRepository.php @@ -63,11 +63,11 @@ class TagRepository * @param User|null $user * @return int */ - public function getIdForSlug($slug, User $user = null) + public function getIdForSlug($slug, User $user = null) : ?int { - $query = Tag::where('slug', 'like', $slug); + $query = Tag::where('slug', $slug); - return $this->scopeVisibleTo($query, $user)->pluck('id'); + return $this->scopeVisibleTo($query, $user)->value('id'); } /**