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
This commit is contained in:
Thomas Lang 2019-06-03 12:00:23 +02:00 committed by Franz Liedke
parent 554e906c2b
commit 0536d10739

View File

@ -63,11 +63,11 @@ class TagRepository
* @param User|null $user * @param User|null $user
* @return int * @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');
} }
/** /**