2017 © Pedro Peláez
 

library countries-laravel

Countries for Laravel

image

pragmarx/countries-laravel

Countries for Laravel

  • Thursday, March 15, 2018
  • by AntonioCarlosRibeiro
  • Repository
  • 4 Watchers
  • 28 Stars
  • 8,804 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 6 Open issues
  • 6 Versions
  • 130 % Grown

The README.md

Countries for Laravel

World Map, (*1)

Latest Stable Version License Code Quality Build , (*2)

Coverage PHP Downloads StyleCI , (*3)

What does it gives you?

This package has all sorts of information about countries:, (*4)

info items
taxes 32
geometry maps 248
topology maps 248
currencies 256
countries 266
timezones 423
borders 649
flags 1,570
states 4,526
cities 7,376
timezones times 81,153

Validation

The validation is extending Laravel's validation, so you can use it like any other validation rules, like, (*5)

/**
 * Store a new blog post.
 *
 * @param  Request  $request
 * @return Response
 */
public function store(Request $request)
{
    $this->validate($request, [
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
        'country' => 'country' //Checks if valid name.common
    ]);

    // The blog post is valid, store in database...
}

Which validation rules there is and what there name should be, can all be configured in the configuration file., (*6)

'validation' => [
    'rules' => [
        'countryCommon' => 'name.common'
    ]
]

By changing the configuration like this, we can now access the property name.common, by the validation rule countryCommon, (*7)

You have to define all the validations rules in settings, only a few is defined by default, the default is, (*8)

'rules'     => [
    'country'           => 'name.common',
    'cca2',
    'cca3',
    'ccn3',
    'cioc',
    'currencies'            => 'ISO4217',
    'language',
    'language_short'    => 'ISO639_3',
]

Documentation

This package is a Laravel bridge, please refer to the main package repository for more information and docs., (*9)

Requirements

  • PHP 7.0+
  • Laravel 5.5+

Installing

Use Composer to install it:, (*10)

composer require pragmarx/countries-laravel

Publishing assets

You can publish configuration by doing:, (*11)

php artisan vendor:publish --provider=PragmaRX\\CountriesLaravel\\Package\\ServiceProvider

Usage

After installing you'll have access to the Countries Façade, and the package is based on Laravel Collections, so you basically have access to all methods in Collections, like, (*12)

$france = Countries::where('name.common', 'France');

Flag routes

You can refer directly to an SVG flag by linking, (*13)

/pragmarx/countries/flag/download/<cca3-code>.svg
/pragmarx/countries/flag/file/<cca3-code>.svg

Examples:, (*14)

https://laravel.com/pragmarx/countries/flag/download/usa.svg
https://laravel.com/pragmarx/countries/flag/file/usa.svg

http://pragmarx.test/pragmarx/countries/flag/file/usa.svg, (*15)

These routes can be turned off in the configuration file:, (*16)

'routes' => [
    'enabled' => false,
]

Author

Antonio Carlos Ribeiro, (*17)

License

Countries is licensed under the MIT License - see the LICENSE file for details, (*18)

Contributing

Pull requests and issues are more than welcome., (*19)

The Versions

15/03 2018

dev-master

9999999-dev

Countries for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel geometry states countries currencies timezones cities flag taxes topology borders

19/02 2018

dev-analysis-qgw27w

dev-analysis-qgw27w

Countries for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel geometry states countries currencies timezones cities flag taxes topology borders

17/02 2018

v0.5.2

0.5.2.0

Countries for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel geometry states countries currencies timezones cities flag taxes topology borders

25/01 2018

v0.5.1

0.5.1.0

Countries for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel geometry states countries currencies timezones cities flag taxes topology borders

24/01 2018

v0.5.0

0.5.0.0

Countries for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel geometry states countries currencies timezones cities flag taxes topology borders

24/01 2018

dev-analysis-qvK2rr

dev-analysis-qvK2rr

Countries for Laravel

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

laravel geometry states countries currencies timezones cities flag taxes topology borders