xxxxxxxxxx
// laravel 8 routing
// get
Route::get('/users', [UserController::class, 'index']);
// resource
Route::resource('/users', UserController::class);
xxxxxxxxxx
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]);
}
xxxxxxxxxx
Route::get('user/profile', [UserProfileController::class, 'show'])->name('profile');
xxxxxxxxxx
Route::get('user/{id}/profile', function ($id) {
//
})->name('profile');
$url = route('profile', ['id' => 1, 'photos' => 'yes']);
// /user/1/profile?photos=yes
xxxxxxxxxx
//Route::currentRouteName() // check
Route::get('/users',function(){
print "Execute";
});
xxxxxxxxxx
Route::pattern('id', '[0-9]+');
Route::get('user/{id}', function ($id) {
// Only executed if {id} is numeric...
});