Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Laravel how to call variable passed to url in the next page

My url now has the value I need which is /search/{$nombor}. How do I call this variable in the next page?
For example, the url is /search/3 and I want to print 3 in the next page.

Here is my code

web.php

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

route::get('/search',[searchController::class, 'search'])->name('web.search');
route::get('/search/{nombor}',[searchController::class, 'daftar'])->name('web.daftar');

searchController.php


class searchController extends Controller
{
    function daftar($nombor){
        return view('dahDaftar', compact ('nombor'));
    }
}

search.blade.php

<td>
    <a href="search/{{ $nama->nombor }}">DAFTAR</a>
</td>

dahDaftar.blade.php

<body>
    <hr>*PRINT HERE*</hr>
</body>

Thank you

>Solution :

You print it out using the same method you’ve used for the {{ $nama->nombor }}, so:

{{ $nombor }}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading