title: How to get and order the most relevant entries from the database with multiple keywords Laravel 5
body: <p>I am having trouble handling multiple keywords and querying the database based on relevance. I want to search each row and if there is more than 1 keyword per row matching based on my selected columns, to sort these entries first.</p>
  
  <p>I do have something working, but it just pulls all entries with a keyword present in a column in no specific order or relevance.</p>
  
  <p>Take this working example:</p>
  
  <pre><code>$search_terms = array('York', 'North Yorkshire');
  
  $properties = Property::where(function ($q) use ($search_terms) {
              foreach ($search_terms as $value) {
                  $q-&gt;orWhere('address1', 'like', "%{$value}%");
                  $q-&gt;orWhere('address2', 'like', "%{$value}%");
                  $q-&gt;orWhere('postcode', 'like', "%{$value}%");
                  $q-&gt;orWhere('city_town', 'like', "%{$value}%");
                  $q-&gt;orWhere('county', 'like', "%{$value}%");
              }
          })-&gt;paginate(25);
  </code></pre>
  
  <p>This works and pulls back all entries with the keywords present in any of my selected columns. In this instance <strong>York</strong> from the <code>city_town</code> column and <strong>North Yorkshire</strong> from the <code>county</code> column. </p>
  
  <p>I need the the query to check each individual row for these keywords and bring back entries where <strong>ALL</strong> of these keywords are present, followed by where one or more is present afterwards (my example does this now).</p>
  
  <p>Many thanks in advance to anyone who can help.</p>