• Stars
    star
    141
  • Rank 259,971 (Top 6 %)
  • Language
    PHP
  • License
    BSD 3-Clause "New...
  • Created almost 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Countries for Laravel

Countries for Laravel

World Map

Latest Stable Version License Code Quality Build

Coverage PHP Downloads StyleCI

What does it gives you?

This package has all sorts of information about countries:

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

/**
 * 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.

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

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

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

'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.

Requirements

  • PHP 7.0+
  • Laravel 5.5+

Installing

Use Composer to install it:

composer require pragmarx/countries-laravel

Publishing assets

You can publish configuration by doing:

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

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

Flag routes

You can refer directly to an SVG flag by linking

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

Examples:

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

These routes can be turned off in the configuration file:

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

Author

Antonio Carlos Ribeiro

License

Countries is licensed under the MIT License - see the LICENSE file for details

Contributing

Pull requests and issues are more than welcome.

More Repositories

1

tracker

Laravel Stats Tracker
PHP
2,824
star
2

health

Laravel Health Panel
PHP
1,879
star
3

countries

Laravel countries and currencies
PHP
1,741
star
4

google2fa

A One Time Password Authentication package, compatible with Google Authenticator.
PHP
1,684
star
5

firewall

Firewall package for Laravel applications
PHP
1,362
star
6

google2fa-laravel

A One Time Password Authentication package, compatible with Google Authenticator for Laravel
PHP
825
star
7

tddd

A Laravel Continuous Integration Package
Vue
727
star
8

version

Laravel App versioning
PHP
565
star
9

laravelcs

Laravel PHP_CodeSniffer
PHP
236
star
10

deeployer

Deploy your Laravel applications via Github or Bitbucket Hooks
PHP
146
star
11

yaml

A Laravel YAML parser and config loader
PHP
110
star
12

zipcode

Zip code searcher
PHP
97
star
13

steroids

Laravel 4 Blade on Steroids
PHP
95
star
14

coollection

Laravel Collection Objectified
PHP
87
star
15

google2fa-qrcode

QRCode for Google2FA
PHP
84
star
16

recovery

Create recovery/backup codes for 2FA
PHP
72
star
17

random

Generate random strings or numeric values
PHP
70
star
18

glottos

A PHP 5.3+ Translation/Localization System
PHP
69
star
19

sqli

A Laravel Artisan SQL Interactive Interface
PHP
60
star
20

support

Support Classes
PHP
58
star
21

ia-arr

Laravel Illuminate Agnostic Arr
PHP
49
star
22

ia-str

Laravel Illuminate Agnostic Str
PHP
46
star
23

ia-collection

Laravel Illuminate Agnostic Collection
PHP
43
star
24

artisan-anywhere

Execute Artisan from anywhere in your Laravel project tree
43
star
25

dev-box

Development Box Provisioning in Ansible
Shell
41
star
26

artisan-tool

Nova Artisan Tool
PHP
35
star
27

glottosAdmin

Glottos Admin Panel and Starter
JavaScript
27
star
28

laravel-installer

Laravel Framework Installer Script for Unlix-Like Systems
Shell
26
star
29

google2fa-starter

Google2FA Starter App
PHP
26
star
30

tddd-starter

Laravel TDDD Starter App
PHP
23
star
31

nova-boolean-datetime-field

A Laravel Nova Boolean DateTime field
PHP
20
star
32

skel

A PHP Package Creator & Skeleton
Shell
12
star
33

health-docker

App Health Panel for Docker Environments
PHP
8
star
34

google2fa-php

A One Time Password Authentication PHP class, compatible with Google Authenticator
PHP
6
star
35

lumen-image-processor

Lumen Image Processor
PHP
5
star
36

http-basic-auth

HTTP Basic Auth middleware for Laravel
Shell
3
star
37

trivia

Trivia database
PHP
3
star
38

vanhack-agentbot

Vanhack Agent Bot
PHP
3
star
39

pragmarx.com

Source of pragmarx.com
PHP
3
star
40

zsh

zsh
Shell
3
star
41

backup-server

backup-server
PHP
3
star
42

googleforms

Post to Google Form Spreadsheets
PHP
2
star
43

sdk

sdk
PHP
1
star
44

fluxbb-style

The FluxBB style for the Laravel forums.
1
star
45

core-libraries

core libraries
PHP
1
star
46

veveystore

Vevey Store
HTML
1
star
47

a17ex

Area 17 Exercice
PHP
1
star
48

church.api

Church API
PHP
1
star