World States

The states component provides you with an interface to manage your states.

As a bonus, 4.854 states are already seeded for you when installing the platform.

In order to provide you with a complex crud functionality inside the admin, the states crud implements the following out of the box:

Admin Interface

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 states section inside "Admin -> Geo Location -> States.
Feel free to explore all available options this section offers.

States List

Seeder Class

The states component provides a seeder class for seeding most known states into your states database table. The seeder only works with an empty states database table.

If you've successfully installed the Varbox platform, you should find the StatesSeeder.php file inside your database/seeds directory and the states.sql file inside your database/sql directory.

You can seed your states, if you haven't done so yet, by using the following artisan command:

php artisan db:seed --class="StatesSeeder"


Let's see the most common things you can do using states.

Get State Country

You can get a state's country by using the country belongs to relation present on the Varbox\Models\State model.

use Varbox\Models\State;

$state = State::find($id);
$country = $state->country;

Fetch State Cities

You can get a state's cities by using the cities has many relation present on the Varbox\Models\State model.

use Varbox\Models\State;

$state = State::find($id);
$cities = $state->cities;

Sort States Alphabetically

You can fetch states in alphabetical order by using the alphabetically query scope present on the Varbox\Models\State model.

use Varbox\Models\State;

$states = State::alphabetically()->get();

Overwrite Bindings

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 state classes available for binding overwrites are:


Found in config/varbox/bindings.php at models.state_model key.
This class represents the state model.


Found in config/varbox/bindings.php at controllers.states_controller key.
This class is used for interactions with the "Admin -> Geo Location -> States".


Found in config/varbox/bindings.php at form_requests.state_form_request key.
This class is used for validating any state when creating or updating.


Found in config/varbox/bindings.php at filters.state_filter key.
This class is used for applying the filtering logic.


Found in config/varbox/bindings.php at sorts.state_sort key.
This class is used for applying the sorting logic.