- Admin Interface
- Seeder Class
- Overwrite Bindings
The cities component provides you with an interface to manage your cities.
As a bonus, 141.488 cities are already seeded for you when installing the platform.
In order to provide you with a complex crud functionality inside the admin, the cities crud implements the following out of the box:
Before going deeper, you should know that there's already a section in the admin from where you can manage all your countries, states and cities.
You can find the cities section inside Admin -> Geo Location -> Cities.
Feel free to explore all available options this section offers.
The cities component provides a seeder class for seeding most known cities into your
cities database table.
The seeder only works with an empty
cities database table.
If you've successfully installed the Varbox platform, you should find the
CitiesSeeder.php file inside your
database/seeds directory and the
cities.sql file inside your
You can seed your cities, if you haven't done so yet, by using the following artisan command:
php artisan db:seed --class="CitiesSeeder"
Let's see the most common things you can do using cities.
Get City Country
You can get a city's country by using the
country belongs to relation present on the
use Varbox\Models\City; $city = City::find($id); $country = $city->country;
Get City State
You can get a city's state by using the
state belongs to relation present on the
use Varbox\Models\City; $city = City::find($id); $state = $city->state;
Sort Cities Alphabetically
You can fetch cities in alphabetical order by using the
alphabetically query scope present on the
use Varbox\Models\City; $cities = City::alphabetically()->get();
In your projects, you may stumble upon the need to modify the behavior of these classes, in order to fit your needs.
Varbox makes this possible via the
config/varbox/bindings.php configuration file. In that file, you'll find every customizable class the platform uses.
For more information on how the class binding works, please refer to the Custom Bindings documentation section.
The city classes available for binding overwrites are:
This class represents the city model.
This class is used for interactions with the "Admin -> Geo Location -> Cities".
This class is used for validating any city when creating or updating.
This class is used for applying the filtering logic.
This class is used for applying the sorting logic.