🔴 Laravel
Beginner
What are Named Routes in Laravel?
Answer
Named routes allow you to give a route a memorable name and then generate URLs or redirects by name instead of hardcoding paths. Assign a name with ->name("users.index"): Route::get("/users", [UserController::class, "index"])->name("users.index"). Generate a URL: route("users.index"). With parameters: route("users.show", ["id" => 1]) or route("users.show", $user) (Eloquent model route-model binding). Redirect by name: redirect()->route("users.index"). Named routes are crucial because if you change a URL path, you only change it in the route definition — all route() calls automatically reflect the new path without updating every view and controller.