laravel/app/Providers/RouteServiceProvider.php

41 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Providers;
2014-08-11 10:13:20 -05:00
2020-08-27 13:36:32 -05:00
use Illuminate\Cache\RateLimiting\Limit;
2014-09-30 21:13:58 -05:00
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
2020-08-27 13:36:32 -05:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
2019-09-10 17:26:00 +02:00
use Illuminate\Support\Facades\Route;
2014-08-11 10:13:20 -05:00
2015-02-22 20:47:03 -06:00
class RouteServiceProvider extends ServiceProvider
{
2019-12-10 08:59:27 -06:00
/**
2023-04-11 17:17:21 -05:00
* The path to your application's "home" route.
2019-12-10 08:59:27 -06:00
*
2022-05-05 14:52:23 -05:00
* Typically, users are redirected here after authentication.
2020-06-24 12:47:56 -05:00
*
2019-12-10 08:59:27 -06:00
* @var string
*/
public const HOME = '/home';
2015-02-22 20:47:03 -06:00
/**
2022-05-05 14:52:23 -05:00
* Define your route model bindings, pattern filters, and other route configuration.
2015-02-22 20:47:03 -06:00
*/
public function boot(): void
2015-02-22 20:47:03 -06:00
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
2020-08-27 13:36:32 -05:00
2020-07-14 14:00:47 -05:00
$this->routes(function () {
Route::middleware('api')
->prefix('api')
2020-07-14 14:00:47 -05:00
->group(base_path('routes/api.php'));
2020-09-11 08:29:38 -05:00
Route::middleware('web')
->group(base_path('routes/web.php'));
2020-07-14 14:00:47 -05:00
});
2015-02-22 20:47:03 -06:00
}
}