Bird
0
0

Consider the following Laravel route definition:

medium📝 component behavior Q4 of 15
Laravel - Routing
Consider the following Laravel route definition:
Route::prefix('user')->group(function () {
    Route::get('settings', [UserSettingsController::class, 'index']);
});
Which URL will trigger the index method of UserSettingsController?
A/user
B/settings
C/user/settings
D/settings/user
Step-by-Step Solution
Solution:
  1. Step 1: Understand Route Prefix

    The Route::prefix('user') method prepends 'user' to all routes inside the group.
  2. Step 2: Analyze Route Path

    The route inside the group is defined as get('settings'), so the full URL becomes '/user/settings'.
  3. Final Answer:

    /user/settings -> Option C
  4. Quick Check:

    URL matches prefix + route path [OK]
Quick Trick: Prefix adds segment before route path [OK]
Common Mistakes:
  • Assuming prefix replaces the route path
  • Ignoring the prefix when forming the URL
  • Confusing route group with middleware

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes