Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1566 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
2 lars 1
<?php
2
 
1145 lars 3
    namespace App\Providers;
2 lars 4
 
1145 lars 5
    use Illuminate\Cache\RateLimiting\Limit;
6
    use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
7
    use Illuminate\Http\Request;
8
    use Illuminate\Support\Facades\RateLimiter;
9
    use Illuminate\Support\Facades\Route;
2 lars 10
 
1145 lars 11
    class RouteServiceProvider extends ServiceProvider
2 lars 12
    {
1145 lars 13
        /**
14
         * The path to the "home" route for your application.
15
         *
16
         * Typically, users are redirected here after authentication.
17
         *
18
         * @var string
19
         */
20
        public const HOME = '/home';
2 lars 21
 
1145 lars 22
        /**
23
         * Define your route model bindings, pattern filters, and other route configuration.
24
         *
25
         * @return void
26
         */
27
        public function boot()
28
        {
29
            $this->configureRateLimiting();
2 lars 30
 
1145 lars 31
            $this->routes( function ()
32
            {
33
                Route::middleware( 'api' )
34
                    ->prefix( 'api' )
35
                    ->group( base_path( 'routes/api.php' ) );
2 lars 36
 
1660 lars 37
                if ( php_sapi_name() != "cli" )
38
                {
39
                    Route::middleware( 'web' )
40
                        ->group( base_path( 'routes/web.php' ) )
41
                        ->prefix( 'backend' )->group( base_path( 'routes/admin.php' ) );
42
                }
1145 lars 43
            } );
44
        }
45
 
46
        /**
47
         * Configure the rate limiters for the application.
48
         *
49
         * @return void
50
         */
51
        protected function configureRateLimiting()
52
        {
53
            RateLimiter::for( 'api', function ( Request $request )
54
            {
55
                return Limit::perMinute( 60 )->by( $request->user()?->id ? : $request->ip() );
56
            } );
57
        }
2 lars 58
    }