<?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 {
/**
* This namespace is applied to your controller routes.
* In addition, it is set as the URL generator's root namespace.
* @var string
*/
protected $namespace = null;
/**
* Define your route model bindings, pattern filters, etc.
* @return void
*/
public function boot() : void {
parent::boot();
$this->configureRateLimiting();
}
/**
* Configure the rate limiters for the application.
* @return void
*/
protected function configureRateLimiting() : void {
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(600)->by(optional($request->user())->id ?: $request->ip());
});
}
/**
* Define the routes for the application.
* @return void
*/
public function map() : void {
$this->mapAuthRoutes();
$this->mapApiRoutes();
$this->mapApiSellerRoutes();
$this->mapAdminRoutes();
$this->mapSellerRoutes();
$this->mapAffiliateRoutes();
$this->mapRefundRoutes();
$this->mapClubPointsRoutes();
$this->mapOtpRoutes();
$this->mapOfflinePaymentRoutes();
$this->mapPosRoutes();
$this->mapSellerPackageRoutes();
$this->mapDeliveryBoyRoutes();
$this->mapAuctionRoutes();
$this->mapWholesaleRoutes();
$this->mapWebRoutes();
$this->mapApiDeliveryRoutes();
$this->mapWebhooksRoutes();
$this->mapPaymentMethodsRoutes();
}
/**
* Define the "api" routes for the application.
* These routes are typically stateless.
* @return void
*/
protected function mapApiRoutes() : void {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api/routes.php'));
}
/**
* Define the "api" routes for the application.
* These routes are typically stateless.
* @return void
*/
protected function mapApiSellerRoutes() : void {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api/seller/routes.php'));
}
/**
* Define the "admin" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapAdminRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/admin.php'));
}
/**
* Define the "seller" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapSellerRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/seller.php'));
}
/**
* Define the "affiliate" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapAffiliateRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/affiliate.php'));
}
/**
* Define the "refund" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapRefundRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/refund_request.php'));
}
/**
* Define the "club points" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapClubPointsRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/club_points.php'));
}
/**
* Define the "OTP System" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapOtpRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/otp.php'));
}
/**
* Define the "offline payment" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapOfflinePaymentRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/offline_payment.php'));
}
/**
* Define the "POS System" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapPosRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/pos.php'));
}
/**
* Define the "seller package" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapSellerPackageRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/seller_package.php'));
}
/**
* Define the "delivery boy" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapDeliveryBoyRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/delivery_boy.php'));
}
/**
* Define the "auction" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapAuctionRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/auction.php'));
}
/**
* Define the "b2b" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapWholesaleRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/wholesale.php'));
}
/**
* Define the "web" routes for the application.
* These routes all receive session state, CSRF protection, etc.
* @return void
*/
protected function mapWebRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "API" routes for delivery options
* @return void
*/
protected function mapApiDeliveryRoutes() : void {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api/delivery/routes.php'));
}
protected function mapAuthRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/auth.php'));
}
protected function mapWebhooksRoutes() : void {
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/webhooks.php'));
}
/**
* Define the "Payment Methods" routes for delivery options
* @return void
*/
protected function mapPaymentMethodsRoutes() : void {
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api/payment_methods/routes.php'));
}
}
|