When we work with a route group, we often find two terms - 'prefix' and 'as'. What's the difference between these two terms? Well, Prefix uses in URL and As is used in name route.
For example, if we write...
Route::group(['prefix' => 'admin'], function(){
Route::get('/index',[DashboardController::class, 'index'])->name('index');
});
the Url works like this:
Route::get('/admin/index',[DashboardController::class, 'index'])->name('index');
But when we use As,such as...
Route::group(['as' => 'admin'], function(){
Route::get('/index',[DashboardController::class, 'index'])->name('index');
});
This will be work like..
Route::get('/index',[DashboardController::class, 'index'])->name('admin.index');
Thanks. Happy coding.
Top comments (0)