Answer the question
In order to leave comments, you need to log in
Is it correct to do so (getting data by key)?
There are categories that have many articles. I need to display all articles and articles by category. Dealt with the first one. In the second case, I think to do this: in the same controller, make a method that will display articles that belong to the selected category, add the path /blog/category_name to the routes, respectively, use the same view, and 'uses'=>'my_method'.
You need to finish the view. Now there is just one that displays all the articles. Need to add another foreach for categories? Or check the path where the view is displayed, and if there is /blog/category_1, then display all the articles that belong to "category_1"? @foreach ($blogs as $blog)
Answer the question
In order to leave comments, you need to log in
In the controller where you get $blogs, add a condition: "if a category is specified, then add SQL-where by category".
The view is unchanged. Unless you can display the name of the category for convenience.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question