i have a problem with this eloquent. how i can pass only the blog that have the attribute categoryid that same as the id that clicked from index.blade.php ?
This is the picture of show.blade.php , the page after click button from index.blade.php
CodePudding user response:
You forgot the get()
method after the where
method on your CategoryController, something like this:
return view('categories.show', [
'category' => $category,
'blog' => Blog::where('categoryid', $category->id)->get(),
]);