Answer the question
In order to leave comments, you need to log in
Implementation of the list area-Region-Populated list?
I created three migrations: 2015_06_22_101717_create_locations_top_level.php (for regions), 2015_06_22_101819_create_locations_middle_level.php (for cities and districts) and 2015_06_22_101851_create_locations_primary_level.php (for towns and villages). And now I need to create a fourth table where the identifiers of these three tables will be stored? And the model for the fourth table? And how to add these regions, cities, villages to the database?
Answer the question
In order to leave comments, you need to log in
If the question is how to store this data in the database, then the scheme is standard: id, parent_id. The root element in your case is the country, its parent_id will be null.
Suppose Dnipropetrovsk region has id = 3, then all ancestors, that is, cities that are part of it, will have parent_id 3. Accordingly, to select them, you need to make a query like:SELECT * FROM table WHERE parent_id = 3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question