laravel routes prefix code example
Example 1: laravel route namespace and prefix
Route::name('admin.')->group(function () {
Route::get('/users', function () {
})->name('users');
});
Example 2: set route name laravel
Route::get('/novanoticia', 'HomeController@getNovaNoticia')->name('route_name');
Route::get('/novanoticia', ['as' => 'route_name', 'uses' => 'HomeController@getNovaNoticia']);
Example 3: laravel route match
Route::match(['get', 'post'], '/', function () {
});
Route::any('/', function () {
});
Example 4: laravel route
Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');
Example 5: laravel route namespace and prefix
use App\Models\User;
Route::get('/users/{user}', function (User $user) {
return $user->email;
});
Example 6: prefix laravel route
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
});