- Admin Interface
- Seeder Class
- Overwrite Bindings
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:
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.
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
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
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
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
use Varbox\Models\State; $states = State::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 state classes available for binding overwrites are:
This class represents the state model.
This class is used for interactions with the "Admin -> Geo Location -> States".
This class is used for validating any state when creating or updating.
This class is used for applying the filtering logic.
This class is used for applying the sorting logic.