[dfae77e] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | namespace App\Providers;
|
---|
| 4 |
|
---|
| 5 | use Illuminate\Cache\RateLimiting\Limit;
|
---|
| 6 | use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
---|
| 7 | use Illuminate\Http\Request;
|
---|
| 8 | use Illuminate\Pagination\Paginator;
|
---|
| 9 | use Illuminate\Support\Facades\RateLimiter;
|
---|
| 10 | use Illuminate\Support\Facades\Route;
|
---|
| 11 |
|
---|
| 12 | class RouteServiceProvider extends ServiceProvider
|
---|
| 13 | {
|
---|
| 14 | /**
|
---|
| 15 | * The path to the "home" route for your application.
|
---|
| 16 | *
|
---|
| 17 | * This is used by Laravel authentication to redirect users after login.
|
---|
| 18 | *
|
---|
| 19 | * @var string
|
---|
| 20 | */
|
---|
| 21 | public const HOME = '/explore';
|
---|
| 22 | public const ARTIST_HOME = '/offers';
|
---|
| 23 | public const ORGANIZER_HOME = '/explore';
|
---|
| 24 | public const MANAGER_HOME = '/artists';
|
---|
| 25 | public const ONBOARDING = '/onboarding';
|
---|
| 26 |
|
---|
| 27 | /**
|
---|
| 28 | * The controller namespace for the application.
|
---|
| 29 | *
|
---|
| 30 | * When present, controller route declarations will automatically be prefixed with this namespace.
|
---|
| 31 | *
|
---|
| 32 | * @var string|null
|
---|
| 33 | */
|
---|
| 34 | // protected $namespace = 'App\\Http\\Controllers';
|
---|
| 35 |
|
---|
| 36 | /**
|
---|
| 37 | * Define your route model bindings, pattern filters, etc.
|
---|
| 38 | *
|
---|
| 39 | * @return void
|
---|
| 40 | */
|
---|
| 41 | public function boot()
|
---|
| 42 | {
|
---|
| 43 | $this->configureRateLimiting();
|
---|
| 44 | Paginator::useBootstrap();
|
---|
| 45 | $this->routes(function () {
|
---|
| 46 | Route::prefix('api')
|
---|
| 47 | ->middleware('api')
|
---|
| 48 | ->namespace($this->namespace)
|
---|
| 49 | ->group(base_path('routes/api.php'));
|
---|
| 50 |
|
---|
| 51 | Route::middleware('web')
|
---|
| 52 | ->namespace($this->namespace)
|
---|
| 53 | ->group(base_path('routes/web.php'));
|
---|
| 54 | });
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | /**
|
---|
| 58 | * Configure the rate limiters for the application.
|
---|
| 59 | *
|
---|
| 60 | * @return void
|
---|
| 61 | */
|
---|
| 62 | protected function configureRateLimiting()
|
---|
| 63 | {
|
---|
| 64 | RateLimiter::for('api', function (Request $request) {
|
---|
| 65 | return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
---|
| 66 | });
|
---|
| 67 | }
|
---|
| 68 | }
|
---|