You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using specific tags to position items on my public pages. To achieve this, I have created a scope to check for the models that have a specific tag. This all works perfectly when using English, the issue is when I change the locale language, those tags change as well, so the posts are no longer found. What I need is a way to specify the locale for the tag being searched for in the withTag() method.
/**
* @param Builder<Post> $query
*/
public function scopeForTag(Builder $query, ?string $tag = null): Builder
{
if ($tag !== null) {
return $query->where(
function ($query) use ($tag) {
$query->withAnyTags([$tag], 'tag');
return $query;
}
);
}
return $query;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using specific tags to position items on my public pages. To achieve this, I have created a scope to check for the models that have a specific tag. This all works perfectly when using English, the issue is when I change the locale language, those tags change as well, so the posts are no longer found. What I need is a way to specify the locale for the tag being searched for in the withTag() method.
Beta Was this translation helpful? Give feedback.
All reactions