xxxxxxxxxx
Route::pattern('id', '[0-9]+');
Route::get('user/{id}', function ($id) {
// Only executed if {id} is numeric...
});
xxxxxxxxxx
Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');
xxxxxxxxxx
Route::view('/welcome', 'welcome');
Route::view('/welcome', 'welcome', ['name' => 'Taylor']);
xxxxxxxxxx
use App\Http\Controllers\UserController;
Route::get('/user', [UserController::class, 'index']);
xxxxxxxxxx
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
//
});
xxxxxxxxxx
Route::get('/user/{id}/profile', function ($id) {
//
})->name('profile');
$url = route('profile', ['id' => 1, 'photos' => 'yes']);
// /user/1/profile?photos=yes
xxxxxxxxxx
// laravel 8 routing
// get
Route::get('/users', [UserController::class, 'index']);
// resource
Route::resource('/users', UserController::class);