Issues (61)

app/Providers/AppServiceProvider.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Gameap\Providers;
4
5
use Gameap\Models\PersonalAccessToken;
6
use Illuminate\Pagination\LengthAwarePaginator;
7
use Illuminate\Pagination\Paginator;
8
use Illuminate\Routing\UrlGenerator;
9
use Illuminate\Support\Collection;
10
use Illuminate\Support\Facades\Schema;
11
use Illuminate\Support\Facades\Validator;
12
use Illuminate\Support\ServiceProvider;
13
use Laravel\Sanctum\Sanctum;
14
use Silber\Bouncer\Bouncer;
15
16
class AppServiceProvider extends ServiceProvider
17
{
18
    /**
19
     * Bootstrap any application services.
20
     *
21
     * @param UrlGenerator $url
22 108
     * @return void
23
     */
24 108
    public function boot(UrlGenerator $url): void
25
    {
26
        Paginator::useBootstrap();
27
        Sanctum::usePersonalAccessTokenModel(PersonalAccessToken::class);
28 108
29 108
        if (strtolower(substr(config('app.url'), 0, 5)) == 'https') {
30
            $url->forceScheme('https');
31 108
        }
32
33 108
        $bouncer = $this->app->get(Bouncer::class);
34 3
        $bouncer->cache();
35
36
        Schema::defaultStringLength(128);
37
38
        Validator::extend('recaptcha', 'Gameap\\Validators\\ReCaptcha@validate');
39
40 3
        if (!Collection::hasMacro('paginate')) {
41
            Collection::macro(
42 108
                'paginate',
43
                function ($perPage = 15, $page = null, $options = []) {
44
                    $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
45
                    return (new LengthAwarePaginator(
46
                        $this->forPage($page, $perPage),
0 ignored issues
show
The method forPage() does not exist on Gameap\Providers\AppServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
                        $this->/** @scrutinizer ignore-call */ 
47
                               forPage($page, $perPage),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
                        $this->count(),
0 ignored issues
show
The method count() does not exist on Gameap\Providers\AppServiceProvider. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
                        $this->/** @scrutinizer ignore-call */ 
48
                               count(),

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
                        $perPage,
49 108
                        $page,
50
                        $options
51
                    ))
52 108
                        ->withPath('');
53
                }
54
            );
55
        }
56
    }
57
58
    /**
59
     * Register any application services.
60
     *
61
     * @return void
62
     */
63
    public function register(): void
64
    {
65
        //
66
    }
67
}
68