Download the PHP package cyberionsys/laravel-countries without Composer
On this page you can find all versions of the php package cyberionsys/laravel-countries. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cyberionsys/laravel-countries
More information about cyberionsys/laravel-countries
Files in cyberionsys/laravel-countries
Package laravel-countries
Short Description A database with ISO country information in all configured translations
License MIT
Homepage https://github.com/cyberionsys/laravel-countries
Informations about the package laravel-countries
Laravel Countries
This package provides ready-to-use application models and seeds the database with ISO data from various sources. This package can be used in multi-language apps and supports Country/Language/Currency names in almost any locale.
Included datasets
- Countries: ISO 3166 alpha 2 (incl. names, capital, lat/lon coordinates, TLD, phone calling code, regions, population, gini, area)
- Languages: ISO 639-1 (incl. names, language-family, wiki link)
- Currencies: ISO 4217 (incl. names, symbol, decimal digits, rounding)
Unlike other packages, this one also includes relevant data relationships, such as:
Installation
You can install the package via composer:
The latest version of this package requires PHP version 8.1 or above.
Migrations
Optionally, you can publish the database migrations with:
By default, this database includes all country/language/¤cy names translated into English, German, French, and Spanish. If you want to compile your own database with other languages, please see the instructions here.
Config
Optionally, you can publish the config file with:
In the config you can define, which translations of country/language/currency names you want to store in your DB.
This is the contents of the published config file:
After making changes to the config you need to re-migrate your database:
Warning This will recreate your entire database. Please take appropriate cautions before running it
Usage
Country model
Language model
Currency model
Query relationships
All models have pre-defined many-to-many relationships that can be queried:
Localized names
Each of the package models (Country, Language, Currency) has a ->name
attribute, which will be displayed in the app's
locale, using the spatie/laravel-translatable package. The default
config will migrate localized names for en
, de
, fr
, and es
. This can be adjusted in the config. The
config app.locale
and app.fallback_locale
are automatically included.
Attribute casting
If you already use ISO codes in your models, you can enrich them by casting them as Country/Language/Currency model:
Testing
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Cyberion Systems
- Original idea from Martin
- https://restcountries.com
- https://github.com/umpirsky/language-list
- https://github.com/umpirsky/currency-list
- https://github.com/spatie/laravel-translatable
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-countries with dependencies
illuminate/contracts Version ^10.0
spatie/laravel-package-tools Version ^1.16.0
spatie/laravel-translatable Version ^6.5
umpirsky/currency-list Version ^1.1
umpirsky/language-list Version ^1.1