laravel-enso / countries
Countries for Laravel Enso
Requires
- laravel-enso/core: ^12.0
- laravel-enso/dynamic-methods: ^4.0
- laravel-enso/enums: ^3.0
- laravel-enso/helpers: ^4.0
- laravel-enso/migrator: ^2.1
- laravel-enso/rememberable: ^4.0
- laravel-enso/select: ^5.0
- laravel/framework: ^10.0|^11.0|^12.0|^13.0
- dev-master
- 2.8.3
- 2.8.2
- 2.8.1
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.1.9
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-upgrade/laravel13-core12
- dev-feature/MediSoftId
- dev-feature/ensoV8
- dev-upgrade/enso6-dr
- dev-upgrade/enso6
- dev-hotfix/regionLabel
- dev-feature/adds-rememberable-keys
- dev-feature/addActiveState
- dev-upgrade/laravel8
- dev-fixes/stylci
This package is auto-updated.
Last update: 2026-04-20 17:09:08 UTC
README
Description
Countries provides the country reference dataset used across the Laravel Enso ecosystem.
The package ships the countries table, a JSON-backed seeder for the full country list, an Eloquent model with a few convenience behaviors, and an authenticated options endpoint meant for select inputs.
It is a foundational backend package for address management, currencies, webshop flows, and any feature that needs normalized country metadata such as ISO codes, currency details, calling codes, or flags.
Installation
This package comes pre-installed in Laravel Enso applications that require country metadata.
For standalone installation in an Enso-based application:
composer require laravel-enso/countries
The package automatically:
- loads its API routes
- loads its migrations
- publishes its seeders when requested
Run the migrations after installation:
php artisan migrate
If you want the package seeder in your application's database seeders directory, publish it with:
php artisan vendor:publish --tag=countries-seeder
Then seed the table:
php artisan db:seed --class="LaravelEnso\Countries\Database\Seeders\CountrySeeder"
Features
- Creates the
countriestable with ISO, currency, region, and calling metadata. - Ships a JSON-backed seeder for the full country dataset.
- Provides an Eloquent
Countrymodel with rememberable lookup keys. - Exposes an authenticated
optionsendpoint for select inputs. - Returns only active countries through the options endpoint.
- Includes a region label helper that adapts for Romania and the United States.
Usage
Fetch active country options through the API:
route('core.countries.options');
Query the model directly:
use LaravelEnso\Countries\Models\Country; $romania = Country::whereIso31662('RO')->firstOrFail(); $label = $romania->regionLabel();
The options endpoint serializes countries in a frontend-friendly shape:
{
"id": 1,
"name": "Romania",
"currencyCode": "RON"
}
::: warning Note The package exposes only active countries through its options endpoint.
If you seed or modify the dataset manually, remember that inactive rows will not be returned by core.countries.options.
:::
API
Routes
All package routes are registered under:
- prefix:
api/core/countries - name prefix:
core.countries. - middleware:
api,auth,core
Endpoints:
GET /api/core/countries/options
Controller
LaravelEnso\Countries\Http\Controllers\Options
Behavior:
- builds select-style options through
LaravelEnso\Select\Traits\OptionsBuilder - filters by active countries only
- allows querying by
nameandiso_3166_3
Resource
LaravelEnso\Countries\Http\Resources\Country
Serialized attributes:
idnamecurrencyCode
Model
LaravelEnso\Countries\Models\Country
Useful traits:
ActiveStateAvoidsDeletionConflictsHasFactoryRememberable
Rememberable keys:
idiso_3166_2name
Useful method:
regionLabel(): string
Seeder
LaravelEnso\Countries\Database\Seeders\CountrySeeder
Reads the dataset from:
vendor/laravel-enso/countries/database/countries.json
Depends On
Required Enso packages:
laravel-enso/core↗laravel-enso/dynamic-methods↗laravel-enso/enums↗laravel-enso/helpers↗laravel-enso/migrator↗laravel-enso/rememberable↗laravel-enso/select↗
Framework dependency:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!