Laravel version update
Laravel version update
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
use ReflectionClass;
|
||||
|
||||
class LaravelPhoneServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Bootstrap the application events.
|
||||
*
|
||||
@@ -13,7 +13,9 @@ class LaravelPhoneServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->app['validator']->extend('phone', 'Propaganistas\LaravelPhone\PhoneValidator@validatePhone');
|
||||
$extend = static::canUseDependentValidation() ? 'extendDependent' : 'extend';
|
||||
|
||||
$this->app['validator']->{$extend}('phone', 'Propaganistas\LaravelPhone\PhoneValidator@validatePhone');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,4 +31,16 @@ class LaravelPhoneServiceProvider extends ServiceProvider
|
||||
|
||||
$this->app->alias('libphonenumber', 'libphonenumber\PhoneNumberUtil');
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether we can register a dependent validator.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function canUseDependentValidation()
|
||||
{
|
||||
$validator = new ReflectionClass('\Illuminate\Validation\Factory');
|
||||
|
||||
return $validator->hasMethod('extendDependent');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use Illuminate\Support\Facades\App;
|
||||
use libphonenumber\PhoneNumberFormat;
|
||||
|
||||
if (! function_exists('phone_format')) {
|
||||
if (! function_exists('phone')) {
|
||||
/**
|
||||
* Get the PhoneNumberUtil or format a phone number for display.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user