How to pass variables in href in Laravel routing
P粉207969787
P粉207969787 2023-08-26 20:05:01
0
1
378

I'm creating a project using Laravel 8, I've created a map using OpenLayers, the map has "points" (or features), each point has a name that's been determined, and every time I click on one of them When I click, a popup appears showing the name of the point and a link that should take me to another page showing more information, the part of the code that gave me the problem is this:

if(feature){ var text = feature.get('name'); content.innerHTML = text ' ' '{{ __('Ver menú') }}>'; }else{ content.innerHTML = ''; }

It threw me this error:

Use of undefined constant text - assuming 'text' (this will throw an error in a future PHP version)

So I'm assuming I can't pass variables like that but I don't know how, here is the route I defined:

Route::get('/local/{nombre}', 'LocalController@index')->name('local'); 

This is the code for the controller:

middleware('auth'); } /*** Show the application dashboard. * * @return IlluminateContractsSupportRenderable*/ public function index($nombre) { return view('local', ['nombre' => $nombre]); }

}

Thank you very much for any advice/tips/information in advance (also, if the code looks a bit messy here, sorry, I'm a newbie and don't know how to give it a proper style, hehe)< /p>

P粉207969787
P粉207969787

reply all (1)
P粉250422045

I think the problem with this part is thetext

{{ route('local',['nombre' => text]) }}

It should be like this

{{ route('local',['nombre' => 'text']) }}

Hope it helps you

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!