title: Posting to the same form in laravel
body: <p>I'm trying to build a search form in Laravel such that when a user presses the search button, all the contacts matching the search criteria are displayed on the same page.</p>
  
  <p>Below is my form:</p>
  
  <pre><code>{{ Form::open(array('url' =&gt; '/directory', 'class' =&gt; 'form-horizontal')) }}
      &lt;div class="form-group"&gt;
          &lt;label for="lastname" class="col-sm-2 control-label"&gt;Last Name&lt;/label&gt;
          &lt;div class="col-sm-6"&gt;
              &lt;input type="text" class="form-control" id="lastname" placeholder="Enter Last Name"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group "&gt;
          &lt;label for="phone" class="col-sm-2 control-label"&gt;Phone&lt;/label&gt;
          &lt;div class="col-sm-6"&gt;
              &lt;input type="text" class="form-control" id="phone" placeholder="Enter Phone number"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;label for="inputEmail1" class="col-sm-2 control-label"&gt;Email&lt;/label&gt;
          &lt;div class="col-sm-6"&gt;
              &lt;input type="email" class="form-control" id="inputEmail1" placeholder="Enter Email - leave blank if you are not sure"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="form-group"&gt;
          &lt;div class="col-lg-offset-2 col-lg-10"&gt;
              &lt;button type="submit" class="btn-u btn-u-green"&gt;Search&lt;/button&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="well"&gt;
          @foreach($users as $user)
              &lt;li&gt;{{$user-&gt;firstname}} {{$user-&gt;lastname}}&lt;/li&gt;
  
          @endforeach
      &lt;/div&gt;
  {{ Form::close() }}
  </code></pre>
  
  <p>The screenshot below gives a pictorial view of my form:</p>
  
  <p><img src="https://i.stack.imgur.com/iHzUl.png" alt="search page"></p>
  
  <p>My route is defined as follow:</p>
  
  <pre><code>Route::get('/directory', 'UsersController@filter');
  </code></pre>
  
  <p>Now, whenever I press the search button, I am getting a <code>MethodNotFound exception</code>.</p>
  
  <p>What I really want to do is to show the search results below the search button.</p>
  
  <p><strong>Edit ..</strong></p>
  
  <p>Everything is working fine now except for one thing.</p>
  
  <p>I'm displaying the data in my view (getting the list of all the users on my page which match the search criteria) but the for loop is not getting executed. </p>
  
  <pre><code>&lt;li&gt;Count of users = {{ $users-&gt;count() }}&lt;/li&gt;
  &lt;li&gt;{{$users-&gt;first()-&gt;lastname}}&lt;/li&gt;
  @foreach ($users as $user)
      &lt;p&gt;This is user {{ $user-&gt;id }}&lt;/p&gt;
  @endforeach
  </code></pre>
  
  <p>So: while I can see the count and the <em>lastname</em> of the first user in the resultant array of records, the foreach loop is not getting executed.</p>
  
  <p>What am I doing wrong?</p>