title: Laravel - passing array of columns in 'where' clause
body: <p>I have a search query like this:  </p>
  
  <pre><code>$data = User::where('first_name', 'like', '%'.$query.'%')
     -&gt;orWhere('last_name', 'like', '%'.$query.'%')
     -&gt;get();
  </code></pre>
  
  <p>Now, I have many models, each with different column names. Instead of defining a <code>search()</code> function into every controller, I want to do this:</p>
  
  <pre><code>// User
  public static function searchableFields()
  {
      return ['first_name', 'last_name'];
  }
  
  // Some other model
  public static function searchableFields()
  {
      return ['name', 'description'];
  }
  </code></pre>
  
  <p>And put the search logic in a shared controller, something like this:</p>
  
  <pre><code>$data = $classname::
      where($classname::searchableFields(), 'like', '%'.$query.'%')
      -&gt;get();
  </code></pre>
  
  <p>How can I achieve this?</p>
  
  <p>Thanks a lot.</p>