afoysal's avatar

Route from Variable

I have a route like below

<a href="{{route('startRun')}}">

But I would like to use Variable like below

<a href="{{route("start".$last_word)}}">

I am getting error like below

Route [startRun ] not defined.

My route in web.php file is like below

Route::get('/run','PublicController@starToRun')->name('startRun');
0 likes
3 replies
SilenceBringer's avatar
Level 56

Hi @afoysal I think your problem is in space at the end of $last_word

<a href="{{route('start' . trim($last_word))}}">

because here

Route [startRun ] not defined.

I see space at the end of route name

1 like
laracoft's avatar
  1. It all looks ok, if you use <a href="{{route("startRun")}}">, is it the same error?
  2. If yes, post your entire web.php
1 like

Please or to participate in this conversation.