There is a Post
model, which has relations PostTags
. Relations can be empty. During the search, I need to get posts, which have certain tags(from search) first, and then all other. To retrieve the only posts, which have certain tags, I can use whereHas
:
$posts->whereHas(
'tags', function(Builder $builder) use ($tags) {
$builder->whereIn('tag_id', $tags);
})
But I need to add the others to the end. Any suggestions on how to do it? Or maybe there is a way to unite whereHas
and orderBy
?
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/37wmL5y
via IFTTT
Aucun commentaire:
Enregistrer un commentaire