title: Laravel 4 - Get Current Route Name on Hidden Input to use for search
body: <p>I have a search form in the nav bar on my Laravel 4 app. When someone types into search and submits I want the queries to only be performed based on what section of the site they are on. Example, if they are on the blog page, I want it to return only blog posts, and if they are on the users page, I want it to only bring up a list of users.</p>
  
  <p>Unless I'm missing something (certainly possibly as I'm new to Laravel!) I can do this using getCurrentRoute()->getPath(). But I have to do this from the form, because when I try to do it in a Controller it does not have the old route any more. So, I created a hidden field on my form like so:</p>
  
  <pre><code>{{ Form::hidden('route', '{{{Route::getCurrentRoute()-&gt;getPath()}}}') }};
  </code></pre>
  
  <p>However, the "getCurrentRoute()->getPath()" is never evaluated properly. The form field literally prints it out:</p>
  
  <pre><code>&lt;input name="route" type="hidden" value="&amp;lt;?php echo e(Route::getCurrentRoute()-&amp;gt;getPath()); ?&amp;gt;"&gt;
  </code></pre>
  
  <p>Does anyone know a way to get this to work, or is there a better way to do this that I'm totally missing? Again, I can't insert this into a controller like normal because at that point the route has been sent to </p>
  
  <pre><code>// Search
  Route::post('search', array('as' =&gt; 'search', 'uses' =&gt; 'SearchController@postSearch'), function(){
  });
  </code></pre>
  
  <p>At which point it always thinks the route name is "search".</p>