1. Go to this page and download the library: Download rdcstarr/laravel-locale library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rdcstarr / laravel-locale example snippets
use Locale;
// All enabled languages
Locale::enabledLanguages();
// Default language
Locale::defaultLanguage();
// Find by ISO 639-1 code
Locale::languageByCode('ro');
// code → id map (useful for seeding)
Locale::enabledLanguageCodeToId();
// Raw query builder
Locale::languages()->where('enabled', true)->get();
use Locale;
// Find by ISO 3166-1 alpha-2 code
Locale::countryByCode('RO');
// Phone prefix (ITU-T E.164, e.g. "+40")
Locale::callingCodeByCode('RO'); // → "+40"
country_calling_code('RO'); // → "+40" (global helper)
Locale::countryByCode('RO')->calling_code; // direct model access
// All countries sharing a calling code (e.g. NANP "+1")
Locale::countries()->byCallingCode('+1')->get();
// All countries that use a given language
Locale::countriesForLanguage('ro');
// code → id map (useful for seeding)
Locale::countryCodeToId();
// Raw query builder
Locale::countries()->with('primaryLanguage')->get();