title: Laravel 4 Build Query where clause on the fly
body: <p>I am porting my code from CodeIgniter to Laravel. and have some question regarding the query builder.</p>
  
  <p>In codeigniter, I can just add where clause to the active record object, as I initialize each property in a class like </p>
  
  <pre><code>$this-&gt;db-&gt;where('xxxx','bbbb'); 
  </code></pre>
  
  <p>in one property initialize function, and </p>
  
  <pre><code>$this-&gt;db-&gt;where('yyyy','aaaa'); 
  </code></pre>
  
  <p>in another property function, and it will all chain up until i fire off the query. But this doesn't seem to be the case of Laravel.</p>
  
  <p>Here is what I do in laravel in each property initialize function</p>
  
  <pre><code>DB::table($this-&gt;table)-&gt;where('xxxx','bbbb');
  DB::table($this-&gt;table)-&gt;where('yyyy','aaa');
  </code></pre>
  
  <p>and when a actual method is call from outside, it runs</p>
  
  <pre><code>DB:table($this-&gt;table)-&gt;get(); 
  </code></pre>
  
  <p>but this gives me a <code>SELECT * FROM TABLENAME</code> without anywhere clause. So what am I doing wrong here :x or I just shouldn't treat laravel same as codeigniter and think of something totally different to handle this kind of dynamic where clause?</p>
  
  <p>Also in codeigniter, you can set a section of the query to cache, so even after you fire off the query , those section retains for next query, usually the where clause. Is there a similar function in Laravel? Thank you!</p>