| 1 | <?php |
||
| 9 | class AppServiceProvider extends ServiceProvider |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Bootstrap any application services. |
||
| 13 | * |
||
| 14 | * @return void |
||
| 15 | */ |
||
| 16 | 5 | public function boot() |
|
| 17 | { |
||
| 18 | // Fixes incompatibility with MySQL < 5.7.7 |
||
| 19 | 5 | Schema::defaultStringLength(191); |
|
| 20 | |||
| 21 | // Create {{ $view_name }} provider in blade templates |
||
| 22 | 5 | view()->composer('*', function($view) { |
|
|
|
|||
| 23 | $view_name = str_replace('.', '-', $view->getName()); |
||
| 24 | view()->share('view_name', $view_name); |
||
| 25 | 5 | }); |
|
| 26 | |||
| 27 | 5 | Validator::extend('phone', function($attribute, $value, $parameters, $validator) { |
|
| 28 | return preg_match('%^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$%i', $value) && strlen($value) >= 10; |
||
| 29 | 5 | }); |
|
| 30 | |||
| 31 | 5 | Validator::replacer('phone', function($message, $attribute, $rule, $parameters) { |
|
| 32 | return str_replace(':attribute', $attribute, ':attribute is invalid phone number'); |
||
| 33 | 5 | }); |
|
| 34 | 5 | } |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Register any application services. |
||
| 38 | * |
||
| 39 | * @return void |
||
| 40 | */ |
||
| 41 | 5 | public function register() |
|
| 45 | } |
||
| 46 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: