Bird
0
0

Why does this route naming cause an error?

medium📝 Debug Q7 of 15
Laravel - Routing
Why does this route naming cause an error?
Route::get('/post', fn() => 'Post')->name();
ANo name string provided inside name()
BRoute URL is missing a slash
CClosure function is missing return statement
DRoute method get is not allowed
Step-by-Step Solution
Solution:
  1. Step 1: Check usage of ->name()

    The name() method requires a string argument specifying the route name.
  2. Step 2: Identify missing argument

    Here, name() is called without any argument, causing an error.
  3. Final Answer:

    No name string provided inside name() -> Option A
  4. Quick Check:

    name() must have a route name string [OK]
Quick Trick: Always provide a string inside ->name('your.name') [OK]
Common Mistakes:
  • Calling name() without argument
  • Confusing route URL with route name
  • Using invalid HTTP methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes