Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Eloquent in Laravel

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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(),
]);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading