82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Flash;
|
|
use App\Models\Pole;
|
|
use App\Models\Employee;
|
|
use App\Models\EmployeeMailToken;
|
|
use App\Models\Site;
|
|
use App\Models\Societe;
|
|
use App\Models\Sondage;
|
|
use App\Models\User;
|
|
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;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class RouteServiceProvider extends ServiceProvider
|
|
{
|
|
/**
|
|
* 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 = '/bo';
|
|
|
|
/**
|
|
* 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'));
|
|
});
|
|
|
|
Route::bind('hashcode', function ($value) {
|
|
// returns nullable
|
|
return EmployeeMailToken::where('hashcode', $value)->firstOrFail();
|
|
});
|
|
|
|
Route::model('sondage', Sondage::class);
|
|
Route::model('employee', Employee::class);
|
|
Route::model('site', Site::class);
|
|
Route::model('pole', Pole::class);
|
|
Route::model('societe', Societe::class);
|
|
Route::model('sondage', Sondage::class);
|
|
Route::model('flash', Flash::class);
|
|
Route::model('user', User::class);
|
|
|
|
parent::boot();
|
|
}
|
|
|
|
/**
|
|
* Configure the rate limiters for the application.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function configureRateLimiting()
|
|
{
|
|
RateLimiter::for('credentials', function (Request $request) {
|
|
return Limit::perMinute(30)->by(optional($request->user())->id ?: $request->ip());
|
|
});
|
|
RateLimiter::for('api', function (Request $request) {
|
|
return Limit::perMinute(60)->by(optional($request->user())->id ?: $request->ip());
|
|
});
|
|
}
|
|
}
|