Bird
0
0

Which of the following is the correct syntax to create a route group with a prefix admin in Laravel?

easy📝 Syntax Q12 of 15
Laravel - Routing
Which of the following is the correct syntax to create a route group with a prefix admin in Laravel?
ARoute::group('prefix' => 'admin', function () { /* routes */ });
BRoute::group(['prefix' => 'admin'], function () { /* routes */ });
CRoute::group(['admin' => 'prefix'], function () { /* routes */ });
DRoute::group(function () { prefix('admin'); /* routes */ });
Step-by-Step Solution
Solution:
  1. Step 1: Recall Route Group Syntax

    Route groups use an array of attributes as the first argument, e.g., ['prefix' => 'admin'].
  2. Step 2: Identify Correct Array Syntax

    Route::group(['prefix' => 'admin'], function () { /* routes */ }); correctly uses the array with 'prefix' key and a closure function.
  3. Final Answer:

    Route::group(['prefix' => 'admin'], function () { /* routes */ }); -> Option B
  4. Quick Check:

    Array with 'prefix' key = correct syntax [OK]
Quick Trick: Use array with 'prefix' key inside Route::group [OK]
Common Mistakes:
  • Missing array brackets around attributes
  • Swapping key and value in array
  • Trying to call prefix() inside the closure

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes