trs_matrimony/app/Providers/RouteServiceProvider.php
2024-08-22 09:31:12 +05:30

145 lines
3.3 KiB
PHP

<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Cache\RateLimiting\Limit;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* The path to the "home" route for your application.
*
* @var string
*/
public const HOME = '/home';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
$this->configureRateLimiting();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapAdminRoutes();
$this->mapSupportTicketRoutes();
$this->mapOtpRoutes();
$this->mapReferralRoutes();
$this->mapWebRoutes();
// $this->mapInstallRoutes();
// $this->mapUpdateRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
protected function mapAdminRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/admin.php'));
}
protected function mapSupportTicketRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/support_tickets.php'));
}
protected function mapOtpRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/otp.php'));
}
protected function mapReferralRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/referral.php'));
}
protected function mapInstallRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/install.php'));
}
protected function mapUpdateRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/update.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(1000)->by(optional($request->user())->id ?: $request->ip());
});
}
}