Merge remote-tracking branch 'refs/remotes/origin/master' into arindam-bug-priority

This commit is contained in:
Manish Verma
2016-11-04 18:23:31 +05:30
parent e4b9755294
commit 775e0561d8
2541 changed files with 59048 additions and 90348 deletions

View File

@@ -7,49 +7,40 @@
[![Total Downloads](https://poser.pugx.org/propaganistas/laravel-phone/downloads)](https://packagist.org/packages/propaganistas/laravel-phone)
[![License](https://poser.pugx.org/propaganistas/laravel-phone/license)](https://packagist.org/packages/propaganistas/laravel-phone)
Adds a phone validator to Laravel 4 and 5 based on the [PHP port](https://github.com/giggsey/libphonenumber-for-php) of [Google's libphonenumber API](https://github.com/googlei18n/libphonenumber) by [giggsey](https://github.com/giggsey).
Adds a phone validator to Laravel 4|5 and Lumen based on the [PHP port](https://github.com/giggsey/libphonenumber-for-php) of [Google's libphonenumber API](https://github.com/googlei18n/libphonenumber) by [giggsey](https://github.com/giggsey).
### Installation
1. In the `require` key of `composer.json` file add the following
Run the following command to install the latest version of the package
```json
"propaganistas/laravel-phone": "~2.0"
```
```bash
composer require propaganistas/laravel-phone
```
2. Run the Composer update command
**Laravel**
```bash
composer update
```
In your app config, add the Service Provider to the `$providers` array
3. In your app config, add the Service Provider to the end of the `$providers` array
```php
'providers' => [
...
Propaganistas\LaravelPhone\LaravelPhoneServiceProvider::class,
],
```
**Laravel 5**
```php
'providers' => [
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
...
Propaganistas\LaravelPhone\LaravelPhoneServiceProvider::class,
],
```
**Laravel 4**
```php
'providers' => [
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...
'Propaganistas\LaravelPhone\LaravelPhoneServiceProvider',
],
```
In your languages directory, add for each language an extra language line for the validator:
4. In your languages directory, add for each language an extra language line for the validator:
```php
```php
"phone" => "The :attribute field contains an invalid number.",
```
```
**Lumen**
In `bootstrap/app.php`, register the Service Provider
```php
$app->register(Propaganistas\LaravelPhone\LaravelPhoneServiceProvider::class);
```
### Usage
@@ -102,11 +93,11 @@ You can also enable more lenient validation (for example, fixed lines without ar
'phonefield' => 'phone:LENIENT,US',
```
### Display
Format a fetched phone value using the helper function. `$country_code` is the country the phone number belongs to.
### Helper function
Format a fetched phone value using the `phone()` helper function. `$country_code` is the country the phone number belongs to.
```php
phone_format($phone_number, $country_code = null, $format = PhoneNumberFormat::INTERNATIONAL)
phone($phone_number, $country_code = null, $format = PhoneNumberFormat::INTERNATIONAL)
```
If no `$country_code` was given, the current application locale will be used as default.
The `$format` parameter is optional and should be a constant of `libphonenumber\PhoneNumberFormat` (defaults to `libphonenumber\PhoneNumberFormat::INTERNATIONAL`)