title: Models/Controller variables - Laravel
body: <p>I have been using Query builder in my controller, however want to move into utilising eloquent and query builder. I want to know the best practice of passing variables between the both of them. I have been through the documentation but still having trouble.</p>
  
  <p>Here is how I am doing it in my controller:</p>
  
  <pre><code>public function getRetailers($city) {    
      $locations = DB::table('retailers_listings')
          -&gt;orderBy('country', 'asc')
          -&gt;Where('city', $city)
          -&gt;get();
  
          $this-&gt;layout-&gt;header = $city;
      $content = View::make('retailers.stores')
          -&gt;with('header', $this-&gt;layout-&gt;header)
          -&gt;with('store_listings', $locations)
  
          if (Request::header('X-PJAX')) {
          return $content;
          } else { 
              $this-&gt;layout-&gt;content = $content; 
          } 
      }
  </code></pre>
  
  <p>How would I do the above with eloquent and in a model? How would I pass the variable $city to the model as it comes in from the view. A bit more in depth advice then what the documentation gives me would be great. </p>