How to send ID to another page in Laravel

Created at 11-Oct-2021 , By samar

How to send ID to another page in Laravel

In this article, we will see how to solve "How to send ID to another page in Laravel".

You can send an ID (variable value) to another page in Laravel using the route method in the anchor tag in the view file by passing the variable to it. You have to just pass data from route to controller and after controller to another view page.
  • Pass variable (id) to another page as route parameter via controller in Laravel

    @php $ID = 1; @endphp
    <a href="{{ route('id.detail', ['id'=>$ID]) }}"> Get id value in another view </a>
    Route::get('get-id/{id}', [HomeController::class, 'getUserDetail'])->name('id.detail');
    public function getUserDetail($id){
        return view('home')->with(['id'=> $id]);
    <!doctype html>
    <html lang="en">
            <!-- Required meta tags -->
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
            <!-- Bootstrap CSS -->
            <script src="" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
            <link href="" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
            <title>Home page !</title>
            <h1> {{ $id }}  </h1>

    Generated URL:




Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.