1 | <?php |
||
9 | class AppServiceProvider extends ServiceProvider |
||
10 | { |
||
11 | /** |
||
12 | * Bootstrap any application services. |
||
13 | * |
||
14 | * @return void |
||
15 | */ |
||
16 | 4 | public function boot() |
|
17 | { |
||
18 | // Fixes incompatibility with MySQL < 5.7.7 |
||
19 | 4 | Schema::defaultStringLength(191); |
|
20 | |||
21 | // Create {{ $view_name }} provider in blade templates |
||
22 | 4 | view()->composer('*', function($view) { |
|
|
|||
23 | 1 | $view_name = str_replace('.', '-', $view->getName()); |
|
24 | 1 | view()->share('view_name', $view_name); |
|
25 | 4 | }); |
|
26 | |||
27 | 4 | 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 | 4 | }); |
|
30 | |||
31 | 4 | Validator::replacer('phone', function($message, $attribute, $rule, $parameters) { |
|
32 | return str_replace(':attribute',$attribute, ':attribute is invalid phone number'); |
||
33 | 4 | }); |
|
34 | 4 | } |
|
35 | |||
36 | /** |
||
37 | * Register any application services. |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | 4 | 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: