Home > Blockchain >  Eloquent in Laravel
Eloquent in Laravel

Time:03-05

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 code of show function in CategoryController.php, the parameter is the id and comes from the 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(),
]);
  • Related