title: Cache data with user filters in Laravel (and not only)
body: <p>Laravel 5.5 + Redis.</p>
  
  <p>Got the following code in controller:</p>
  
  <pre><code>$products = Cache::remember('category_'.$category-&gt;alias.'_page_'.$page, 1440, function() use ($childrenCategoriesIndexes){
    return Product::whereIn('category_id', $childrenCategoriesIndexes)
                          -&gt;userFilter()
                          -&gt;paginate(15);
  });
  </code></pre>
  
  <p>It caches each page. But what if there are too many custom filters? This is <code>scopeUserFilter()</code> from <code>Product</code> model: </p>
  
  <pre><code>public function scopeUserFilter($query) {
          if (request('price_from')) {
              $query-&gt;where('price', '&gt;', request('price_from'));
          }
          if (request('price_to')) {
              $query-&gt;where('price', '&lt;', request('price_to'));
          }
          return $query;
      }
  </code></pre>
  
  <p>And there're only 2 variables. But what if there will be 10 and more variables, how to cache this data? I think keys like this are not good:</p>
  
  <p><code>'category_'.$category-&gt;alias.'_page_'.$page.'_'.request('price_from').'_'.request('price_to')</code></p>