$category = 'Laravel';
$posts = Post::with('user', 'category')->whereHas('category', function($query) use ($category) {
$query->where('name', '=', $category);
})->get();
Well.. thanx Zenry :)
I skipped trough the solution found in the documentation cause of the use ($category).
Never to late to review my low knowledge of closures ;)
Thanks Zenry... this is exactly what I was looking for..
ste-m your previous solution also works fine.. Thanks for sharing
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community