Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Country > State > City field #24

Open
tabacitu opened this issue Dec 15, 2020 · 2 comments
Open

Country > State > City field #24

tabacitu opened this issue Dec 15, 2020 · 2 comments

Comments

@tabacitu
Copy link
Member

This SO question made me realise it's not that easy to create this inside Backpack. I mean sure we have a way, but it's not dead-simple, where you just make one call that adds these 3 fields, with the entire database of Countries, States and Cities to it. And... it could be... 😂

https://stackoverflow.com/questions/64477629/how-to-the-dependent-dropdown-in-laravel-backpack-of-country-state-and-city

Don't know how many people would be interested in this though. Do people still use this way of adding location information, or does everybody use the address_google or address_algolia -like fields?

Food for thought.

@promatik
Copy link

I think if you don't need to much precision, google or algolia are ok.

Once I had to create a system to support the Portuguese administrative regions, District > County > Parish (I believe many countries use a similar model). And I needed that clear division between administrative regions, to then query my models over that.

It was painful back then 😬 nowadays, this would have been much easier, if I used fetch operations, and the new relationship field with the dependencies attribute.

In my case, Country > State > City field wouldn't have been enough, if we are going to create a plugin for this we may take into account that many country administrative regions are different.


What I think it would be a possible option, and very likely to fit everyone's needs, is to create some king of relationship_dependency. Where the developer could setup his own Models.

[
    'type' => "relationship_dependency",
    'name' => 'address',
    'entities' => [
        App\Models\Country::class,
        App\Models\State::class => 'country', // 'country' is the method defining the relationship to the previous model
        App\Models\City::class => 'state', // 'state' is the method defining the relationship to the previous model
    ],
]

And this would create 3 selects depending on each other.

Again, I think this is not that hard to achieve with the current relationship field using the dependencies attribute.

@tabacitu
Copy link
Member Author

Yeah... relationship_dependency sounds like a good name for it. Hopefully it doesn't go the way of checklist_dependency 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants