title: Laravel filter date range with date range columns
body: <p>If the selected dates ($postFr, $postTo) are within defined periods, I want to list the related products. So can I do something like the following example?</p>
  <p>example:</p>
  <pre><code>$q-&gt;whereBetween('start_date', array($postFr, $postTo));
  $q-&gt;orWhereBetween('end_date', array($postFr, $postTo));
  
  //Could there be a similar use like this???;
  
  $q-&gt;whereBetween(array(start_date, end_date), $postFr);
  $q-&gt;orWhereBetween(array(start_date, end_date), $postTo);
  </code></pre>
  <p><strong>Detailed explanation:</strong></p>
  <p>I have a periods table like this</p>
  <pre><code>periods
  
  |  id  |  start_date  |  end_date  | product_id |   
  |------|--------------|------------|------------|
  |  1   | 2021-02-19   | 2021-03-21 |  1         |   
  |  2   | 2021-02-19   | 2021-03-21 |  2         |   
  |  3   | 2021-02-19   | 2021-03-21 |  3         |   
  |  4   | 2021-02-19   | 2021-03-21 |  2         |   
  
  </code></pre>
  <p>and I have a products table like this</p>
  <pre><code>products
  
  |   id  |   name    |
  |-------|-----------|
  |   1   |   pro1    |
  |   2   |   pro2    |
  |   3   |   pro3    |
  </code></pre>
  <p>The relevant codes on my model page are as follows</p>
  <pre><code>public $belongsTo = [
          'relationPeriod' =&gt; [
              'Model-&gt;periods table',
              'key' =&gt; 'id',
              'otherKey' =&gt; 'product_id',
          ]
   ]
   
   $query-&gt;whereHas('relationPeriod', function($q) use ($postFr, $postTo){
       $q-&gt;whereBetween('start_date', array($postFr, $postTo]));
       $q-&gt;orWhereBetween('end_date', array($postFr, $postTo));
   });
  </code></pre>