Server : Apache System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64 User : tradze ( 1001) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/tradze/public_html/dev-test/app/Providers/ |
<?php
namespace App\Providers;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to the "home" route for your application.
*
* @var string
*/
public const HOME = '/';
/**
* The controller namespace for the application.
*
* @var string|null
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
$this->mapModuleRoutes();
});
}
/**
* Load module routes from each module's Http/routes.php.
*
* @return void
*/
protected function mapModuleRoutes()
{
$modulesPath = config('modules.path', app_path('Modules'));
if (!is_dir($modulesPath)) {
return;
}
$dirs = glob($modulesPath . '/*', GLOB_ONLYDIR);
foreach ($dirs as $dir) {
$name = basename($dir);
$routesFile = $dir . '/Http/routes.php';
if (file_exists($routesFile)) {
Route::middleware('web')
->namespace('App\\Modules\\' . $name . '\\Http\\Controllers')
->group($routesFile);
}
}
}
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
});
}
}