Bird
0
0

What is wrong with this Laravel route definition?

medium📝 Debug Q6 of 15
Laravel - Routing
What is wrong with this Laravel route definition?
Route::get('/dashboard', fn() => 'Dashboard')->name;
AThe route callback should not be an arrow function
BThe ->name method is called without parentheses and a route name string
CThe HTTP verb 'get' is invalid and should be 'post'
DThe route path '/dashboard' is missing a leading slash
Step-by-Step Solution
Solution:
  1. Step 1: Check method usage

    The ->name method requires parentheses with a string argument specifying the route name.
  2. Step 2: Identify error

    Here, ->name is used without parentheses or a name, which is invalid syntax.
  3. Final Answer:

    The ->name method is called without parentheses and a route name string -> Option B
  4. Quick Check:

    Always call ->name('routeName') with parentheses [OK]
Quick Trick: Always use ->name('name') with parentheses [OK]
Common Mistakes:
  • Omitting parentheses when calling ->name()
  • Passing no argument to ->name()
  • Confusing arrow functions with route naming syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes