title: Dynamic search -- Laravel whereRaw not working
body: <p>I am trying to search for a record in the Individualprofile model based on a search key. The route below when viewed from the browser throws a <code>Call to undefined method Illuminate\Database\Eloquent\Collection::whereRaw()</code> exception.</p>
  
  <p>Inside the foreach loop I have tried <code>Individualprofile::whereRaw(..)</code> but still the same problem. </p>
  
  <p>Below is my full route implementation. </p>
  
  <pre><code>Route::get('/get-individualprofiles',function(){
          $text = "Lamin";
          if(trim($text) == ""){
              return Individualprofile::take(10)-&gt;get();
          }
  
          $substr = preg_split("/[\s,.()&amp;;:_-]+/",preg_replace("/(\w+)/","%$1%",trim($text)),-1,PREG_SPLIT_NO_EMPTY);
  
          $profiles = Individualprofile::all();
          foreach ($substr as $key) {
              $profiles = $profiles-&gt;whereRaw('(name like ? or mobile like ? or address like ? or occupation like ? or mstatus like ?)',[$key,$key,$key,$key,$key]);
          }
          return $profiles-&gt;take(100)-&gt;get();
      });
  </code></pre>