mirror of
https://github.com/flarum/framework.git
synced 2025-02-24 17:07:24 +08:00
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:
parent
554e906c2b
commit
0536d10739
@ -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');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user