route dunction in laravel code example
Example 1: laravel route
# Using Request
Route::get('user/{name}', function (Request $request) {
return $request->route('name');
});
Example 2: laraval routing
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]);
}