hypothetical/app/Providers/RouteServiceProvider.php

41 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
2019-10-31 17:24:53 -04:00
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
2023-05-05 15:31:58 -04:00
* The path to your application's "home" route.
*
2022-05-23 21:01:33 -04:00
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/dashboard';
/**
2022-05-23 21:01:33 -04:00
* Define your route model bindings, pattern filters, and other route configuration.
2016-08-19 16:38:49 -04:00
*/
2023-03-13 17:33:19 -04:00
public function boot(): void
2016-08-19 16:38:49 -04:00
{
2023-05-05 15:31:58 -04:00
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
$this->routes(function () {
2022-05-23 21:01:33 -04:00
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
2016-08-19 16:38:49 -04:00
}
}