Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1144 | Revision 1565 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 1144 Revision 1145
Zeile 1... Zeile 1...
1
<?php
1
<?php
Zeile 2... Zeile 2...
2
 
2
 
Zeile 3... Zeile 3...
3
namespace App\Providers;
3
    namespace App\Providers;
4
 
4
 
5
use Illuminate\Cache\RateLimiting\Limit;
5
    use Illuminate\Cache\RateLimiting\Limit;
6
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
6
    use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
7
use Illuminate\Http\Request;
7
    use Illuminate\Http\Request;
8
use Illuminate\Support\Facades\RateLimiter;
-
 
9
use Illuminate\Support\Facades\Route;
-
 
10
 
-
 
11
class RouteServiceProvider extends ServiceProvider
-
 
12
{
-
 
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';
-
 
21
 
-
 
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();
-
 
30
 
-
 
31
        $this->routes(function () {
-
 
32
            Route::middleware('api')
-
 
33
                ->prefix('api')
-
 
34
                ->group(base_path('routes/api.php'));
-
 
35
 
-
 
36
            Route::middleware('web')
-
 
37
                ->prefix( 'backend' )->group(base_path('routes/admin.php'))
-
 
38
                ->group(base_path('routes/web.php'));
-
 
Zeile 39... Zeile -...
39
        });
-
 
40
    }
8
    use Illuminate\Support\Facades\RateLimiter;
41
 
-
 
42
    /**
-
 
43
     * Configure the rate limiters for the application.
-
 
44
     *
-
 
45
     * @return void
9
    use Illuminate\Support\Facades\Route;
-
 
10
 
-
 
11
    class RouteServiceProvider extends ServiceProvider
-
 
12
    {
-
 
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';
-
 
21
 
-
 
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();
-
 
30
 
-
 
31
            $this->routes( function ()
-
 
32
            {
-
 
33
                Route::middleware( 'api' )
-
 
34
                    ->prefix( 'api' )
-
 
35
                    ->group( base_path( 'routes/api.php' ) );
-
 
36
 
-
 
37
                Route::middleware( 'web' )
-
 
38
                    ->group( base_path( 'routes/web.php' ) )
-
 
39
                    ->prefix( 'backend' )->group( base_path( 'routes/admin.php' ) );
-
 
40
            } );
-
 
41
        }
-
 
42
 
-
 
43
        /**
-
 
44
         * Configure the rate limiters for the application.
-
 
45
         *
-
 
46
         * @return void
46
     */
47
         */
-
 
48
        protected function configureRateLimiting()
47
    protected function configureRateLimiting()
49
        {
-
 
50
            RateLimiter::for( 'api', function ( Request $request )
48
    {
51
            {
49
        RateLimiter::for('api', function (Request $request) {
52
                return Limit::perMinute( 60 )->by( $request->user()?->id ? : $request->ip() );
50
            return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
-