2022-05-20 11:54:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Providers;
|
|
|
|
|
|
2022-10-11 15:52:04 +02:00
|
|
|
use App\Lib\Helpers\ToolboxHelper;
|
2022-06-02 14:45:23 +02:00
|
|
|
use App\Models\News;
|
2022-07-18 08:24:42 +00:00
|
|
|
use App\Models\Product;
|
|
|
|
|
use App\Models\Range;
|
2022-06-02 14:45:23 +02:00
|
|
|
use App\Models\Slider;
|
2022-05-20 11:54:44 +02:00
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 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 = '/home';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Define your route model bindings, pattern filters, etc.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function boot()
|
|
|
|
|
{
|
|
|
|
|
$this->configureRateLimiting();
|
|
|
|
|
|
2022-06-01 13:41:24 +02:00
|
|
|
ToolboxHelper::cspReportRoute();
|
|
|
|
|
|
2022-05-20 11:54:44 +02:00
|
|
|
$this->routes(function () {
|
2022-06-01 13:41:24 +02:00
|
|
|
Route::middleware('web')
|
2022-05-20 11:54:44 +02:00
|
|
|
->namespace($this->namespace)
|
2022-06-01 13:41:24 +02:00
|
|
|
->group(base_path('routes/web-bo.php'));
|
2022-05-20 11:54:44 +02:00
|
|
|
|
|
|
|
|
Route::middleware('web')
|
|
|
|
|
->namespace($this->namespace)
|
2022-06-01 13:41:24 +02:00
|
|
|
->group(base_path('routes/web-fo.php'));
|
2022-05-20 11:54:44 +02:00
|
|
|
});
|
2022-06-02 14:45:23 +02:00
|
|
|
|
2022-07-18 08:24:42 +00:00
|
|
|
Route::model('product', Product::class);
|
|
|
|
|
Route::model('range', Range::class);
|
2022-06-02 14:45:23 +02:00
|
|
|
Route::model('slider', Slider::class);
|
|
|
|
|
Route::model('news', News::class, function ($value) {
|
|
|
|
|
return News::where(function ($q) use ($value) {
|
|
|
|
|
$q->whereSlug($value)->orWhere('id', $value);
|
|
|
|
|
})->firstOrFail();
|
|
|
|
|
});
|
2022-05-20 11:54:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Configure the rate limiters for the application.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function configureRateLimiting()
|
|
|
|
|
{
|
2022-06-01 13:41:24 +02:00
|
|
|
RateLimiter::for('web', function (Request $request) {
|
|
|
|
|
return Limit::perMinute(150)->by(optional($request->user())->id ?: app('clientIp'));
|
2022-05-20 11:54:44 +02:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|