i queryed the Category to get all the id where the 'name', '=', $name
and use the result to query Post table
here is the code
public function getList($name){
$category_id = Category::where('name', '=', $name)
->first()->id;
$posts =Post::whereHas("category", function($q) use ($category_id){
$q->where('id','=',$category_id);
})
->paginate(12);
return view('blog.index')
->withPosts($posts)
->withName($name);
}
but i got this error
ErrorException in Builder.php line 877:
compact(): Undefined variable: operator
Pls how can i solve this issue, its urgent
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire