pranpegu/laravel-countries is a Laravel package for simple laravel country list.
It currently has 0 GitHub stars and 3.830 downloads on Packagist (latest version v1.0.0).
Install it with composer require pranpegu/laravel-countries.
Discover more Laravel packages by pranpegu
or browse all Laravel packages to compare alternatives.
Last updated
composer require pranpegu/laravel-countries --dev
Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
Pranpegu\LaravelCountries\CountriesServiceProvider::class,
You can now easily get the list of Countries with dial_code and prefix
use Pranpegu\LaravelCountries\Countries;
$countries = Countries::all(); //returns the array of countries name, dial_code and prefix
foreach($countries as $country){
echo $country['name'].",".$country['dial_code'].",".$country['code'].",";
//eg : Idia,91,IN
}
//or in blade file
<select class="form-group" name="country" >
@foreach($countries as $country)
<option value="{{$country['name']}}" >{{$country['name']}}</option>
@endforeach
</select>
//can also use for getting phone(dial code) code
<select class="form-group" name="dial_code" >
@foreach($countries as $country)
<option value="{{$country['dial_code']}}" >{{$country['dial_code']}}</option>
@endforeach
</select>
//similarly as Country prefix
<select class="form-group" name="code" >
@foreach($countries as $country)
<option value="{{$country['code']}}" >{{$country['code']}}</option>
@endforeach
</select>
Copyright © Ffegu
Laravel Countries is open-sourced software licensed under the MIT license.