Laravel Obtenha o nome da rota atual
Route::currentRouteName()
Beautiful Bird
Route::currentRouteName()
use App\Http\Controllers\UserController;
use App\Models\User;
// Route definition...
Route::get('/users/{user}', [UserController::class, 'show']);
// Controller method definition...
public function show(User $user)
{
return view('user.profile', ['user' => $user]);
}
Route::get('user/{id}', function ($id) {
return 'User '.$id;
});
Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
//
});
// laravel 8 routing
// get
Route::get('/users', [UserController::class, 'index']);
// resource
Route::resource('/users', UserController::class);