Answer the question
In order to leave comments, you need to log in
How to properly implement categories in laravel?
There are categories, but there are news, publications and the like. This raises the question of how to combine them. Enough field "categories" in the table of publications, or make a separate table publication_category (publication_id | category_id), which will store the category to which the entry belongs.
The first option seems to be correct and according to the rules of normal forms, and easier to use (you don’t have to determine the categories from the string and further search), and the second option stores less information, but you have to do additional processing.
And here comes the second question. I don't know why, but I made the address of the admin panel dynamic (and I have all the system settings in the database) and now I have problems with it, because in some places, and in particular controllers. Is it possible to somehow transfer the settings from the database to a separate config? The problem is that I can't make queries to the database in the configs and because of this I can't do it.
Answer the question
In order to leave comments, you need to log in
As for the categories, I recently unsubscribed on this topic to the question How to remove all posts from categories? .
For the second question, you can. Use config for this . Let's create a config/cms.php
file for example :
return [
'news_per_page' => 10
]
config('cms.news_per_page');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question