May a single post have multiple categories with the same name ("headlines" in this case)?
post have multiple categories, "headlines" are one of them.. and no, a single post, can't have 2 "headlines" category or any 2 same category
what i need to do is, sort the posts, dpending on the category.
In that case, I think something like this could be done (never tested it, though):
$headlines = Post::with(array('categories' => function($query) {
$query->where('name', 'headlines');
}))->whereHas('categories', function($query) {
$query->where('name', 'headlines');
})->where('published_at', Session::get('date'))->get()->sortBy(function($post) {
return $post->categories->first()->id;
});
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community