LinkStackOrg /
LinkStack
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace App\Providers; |
||||||
| 4 | |||||||
| 5 | use Illuminate\Support\Facades\Validator; |
||||||
| 6 | use Illuminate\Support\ServiceProvider; |
||||||
| 7 | use Illuminate\Pagination\Paginator; |
||||||
| 8 | use Illuminate\Support\Facades\DB; |
||||||
| 9 | use Illuminate\Support\Facades\View; |
||||||
| 10 | |||||||
| 11 | class AppServiceProvider extends ServiceProvider |
||||||
| 12 | { |
||||||
| 13 | /** |
||||||
| 14 | * Register any application services. |
||||||
| 15 | * |
||||||
| 16 | * @return void |
||||||
| 17 | */ |
||||||
| 18 | public function register() |
||||||
| 19 | { |
||||||
| 20 | // |
||||||
| 21 | } |
||||||
| 22 | |||||||
| 23 | /** |
||||||
| 24 | * Bootstrap any application services. |
||||||
| 25 | * |
||||||
| 26 | * @return void |
||||||
| 27 | */ |
||||||
| 28 | public function boot() |
||||||
| 29 | { |
||||||
| 30 | Paginator::useBootstrap(); |
||||||
| 31 | Validator::extend('isunique', function ($attribute, $value, $parameters, $validator) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 32 | $value = strtolower($value); |
||||||
| 33 | $query = DB::table($parameters[0])->whereRaw("LOWER({$attribute}) = ?", [$value]); |
||||||
| 34 | |||||||
| 35 | if (isset($parameters[1])) { |
||||||
| 36 | $query->where($parameters[1], '!=', $parameters[2]); |
||||||
| 37 | } |
||||||
| 38 | |||||||
| 39 | return $query->count() === 0; |
||||||
| 40 | }); |
||||||
| 41 | Validator::extend('exturl', function ($attribute, $value, $parameters, $validator) { |
||||||
|
0 ignored issues
–
show
The parameter
$parameters is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$validator is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||
| 42 | $allowed_schemes = ['http', 'https', 'mailto', 'tel']; |
||||||
| 43 | return in_array(parse_url($value, PHP_URL_SCHEME), $allowed_schemes, true); |
||||||
| 44 | }); |
||||||
| 45 | View::addNamespace('blocks', base_path('blocks')); |
||||||
| 46 | } |
||||||
| 47 | } |
||||||
| 48 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.