akaunting/app/Providers/Route.php

187 lines
4.4 KiB
PHP
Raw Normal View History

2019-11-16 10:21:14 +03:00
<?php
namespace App\Providers;
2020-10-14 17:07:59 +03:00
use Illuminate\Cache\RateLimiting\Limit;
2019-11-16 10:21:14 +03:00
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as Provider;
2020-10-14 17:07:59 +03:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route as Facade;
2019-11-16 10:21:14 +03:00
class Route extends Provider
{
2020-10-14 17:07:59 +03:00
/**
* The path to the "home" route for your application.
*
* This is used by Laravel authentication to redirect users after login.
*
* @var string
*/
public const HOME = '/';
2019-11-16 10:21:14 +03:00
/**
* 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';
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapInstallRoutes();
$this->mapApiRoutes();
$this->mapCommonRoutes();
$this->mapGuestRoutes();
$this->mapWizardRoutes();
$this->mapAdminRoutes();
$this->mapPortalRoutes();
$this->mapSignedRoutes();
}
/**
* Define the "install" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapInstallRoutes()
{
Facade::prefix('install')
->middleware('install')
->namespace($this->namespace)
->group(base_path('routes/install.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
2020-10-14 17:07:59 +03:00
$this->configureRateLimiting();
2019-11-16 10:21:14 +03:00
Facade::prefix('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
/**
* Define the "common" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapCommonRoutes()
{
2021-04-16 00:59:43 +03:00
Facade::prefix('{company_id}')
->middleware('common')
2019-11-16 10:21:14 +03:00
->namespace($this->namespace)
->group(base_path('routes/common.php'));
}
/**
* Define the "guest" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapGuestRoutes()
{
Facade::middleware('guest')
->namespace($this->namespace)
->group(base_path('routes/guest.php'));
}
/**
* Define the "wizard" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWizardRoutes()
{
2021-04-16 00:59:43 +03:00
Facade::prefix('{company_id}/wizard')
2019-11-16 10:21:14 +03:00
->middleware('wizard')
->namespace($this->namespace)
->group(base_path('routes/wizard.php'));
}
/**
* Define the "admin" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapAdminRoutes()
{
2021-04-16 00:59:43 +03:00
Facade::prefix('{company_id}')
->middleware('admin')
2019-11-16 10:21:14 +03:00
->namespace($this->namespace)
->group(base_path('routes/admin.php'));
}
/**
* Define the "portal" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapPortalRoutes()
{
2021-04-16 00:59:43 +03:00
Facade::prefix('{company_id}/portal')
2019-11-16 10:21:14 +03:00
->middleware('portal')
->namespace($this->namespace)
->group(base_path('routes/portal.php'));
}
/**
* Define the "signed" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapSignedRoutes()
{
2021-04-16 00:59:43 +03:00
Facade::prefix('{company_id}/signed')
2019-11-16 10:21:14 +03:00
->middleware('signed')
->namespace($this->namespace)
->group(base_path('routes/signed.php'));
}
2020-10-14 17:07:59 +03:00
/**
* Configure the rate limiters for the application.
*
* @return void
*/
protected function configureRateLimiting()
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60);
});
}
2019-11-16 10:21:14 +03:00
}