Skip to content

Instantly share code, notes, and snippets.

@frikishaan
Last active December 3, 2022 09:08
Show Gist options
  • Save frikishaan/447fac5cf1224b6661e66f910b752710 to your computer and use it in GitHub Desktop.
Save frikishaan/447fac5cf1224b6661e66f910b752710 to your computer and use it in GitHub Desktop.
How to Generate Routes with Name and Route Prefix?
<?php
...
Route::prefix('/users')->middleware(['auth'])->name('users.')->group(function (){
Route::get('', function(){
return "Users";
})->name('index'); // Will generate Route ('/users') with name ('users.index')
Route::get('/edit', function(){
return "Users Edit";
})->name('edit'); // Will generate Route ('/users/edit') with name ('users.edit')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment