title: Laravel Eloquent Query error
body: <p>I Have been trying to run the following controller in the Laravel 4.0 Framework. Any ideas whats wrong with my controller?:</p>
  
  <pre><code>public function results()
      {   
          $query = DB::table('Unions'); // Get the table before applying the where clauses
  
          if (Request::get('Affilation')) {
              $Affilation = input::get('Affilation');
              if ($Affilation != null) {
                  $query = $query-&gt;where('Affilation', $Affilation);
              }
          }
  
          if (Request::get('Office_State')) {
              $Office_State = input::get('Office_State');
              if ($Office_State != null) {
                  $query = $query-&gt;where('Office_State', $Office_State);
              }
          }
  
          if (Request::has('Local_Name')) {
              $Local_Name = input::get('Local_Name');
              if ($Local_Name != null) {
                  $query = $query-&gt;where('Local_Name', $Local_Name);
              }
          }
  
          $results = $query-&gt;get(); // Calling get() will execute the query, so it must be last to be called
          //show results from union search
          return View::make('results')-&gt;with('union', $results);
       } 
  </code></pre>