Files
app3/app/Providers/RouteServiceProvider.php
2026-01-18 18:03:20 +00:00

52 lines
1.3 KiB
PHP

<?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;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to your application's route files.
*
* @var string
*/
protected $routesPath;
/**
* Define your route model bindings, pattern filters, and other route configuration.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
//$this->routesPath = base_path('routes');
//$this->routes(function () {
//Route::middleware('web')
//->group($this->routesPath . '/web.php');
//Route::middleware(['web', 'auth'])
//->prefix('admin')
//->group($this->routesPath . '/admin.php');
//});
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
}