<?php
namespace AppProviders;
use IlluminateCacheRateLimitingLimit;
use IlluminateFoundationSupportProvidersRouteServiceProvider as ServiceProvider;
use IlluminateHttpRequest;
use IlluminateSupportFacadesRateLimiter;
use IlluminateSupportFacadesRoute;
class RouteServiceProvider extends ServiceProvider
{
/**
* The path to your application's "home" route.
*
* Typically, users are redirected here after authentication.
*
* @var string
*/
public const HOME = '/home';
public function boot(): void
{
RateLimiter::for('api', function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});$this->routes(function () {
Route::middleware('api')
->prefix('api')
->group(base_path('routes/api.php'));
Route::middleware('web')
->group(base_path('routes/web.php'));
});
}
}
I’m currently working with Laravel 11 and encountered an issue where I can’t find the HOME constant class that was available in earlier versions. I want to change the default path for the HOME constant, which is currently set to /home. Can someone guide me on how to do this in the latest version
2
Answers
Modify the HOME constant:
public const HOME = ‘/new_path’;
Make sure you have a route defined for the new home path in your routes/web.php
Route::get(‘/new_path’, [ExampleController::class, ‘exampleMethod’])->name(‘new_path’);
The HOME constant has been removed from the RouteServiceProvider in laravel 11,Please
set a default redirect path.