title: Laravel determine the date from database if MONDAY-SUNDAY
body: <p>Good day gorgeous friends on the internet!</p>
  
  <p>I have a query to get data from database per week. Now I can get a result as you can see in the picture below.</p>
  
  <p>Query:</p>
  
  <pre><code>         return static::selectRaw('SUM(total) as total')
              -&gt;selectRaw('COUNT(*) as total_orders')
              -&gt;whereBetween('created_at', [now()-&gt;startOfWeek(), now()-&gt;endOfWeek()])
              -&gt;whereNotIn('status', ['canceled', 'refunded'])
              -&gt;selectRaw('EXTRACT(DAY FROM created_at) as day')
              -&gt;groupBy(DB::raw('EXTRACT(DAY FROM created_at)'))
              -&gt;orderby('day')
              -&gt;get();
  </code></pre>
  
  <p>and in my controller</p>
  
  <pre><code>        return response()-&gt;json([
              'data' =&gt; Order::salesAnalytics(),
          ]);
  </code></pre>
  
  <p><strong>RESULT</strong></p>
  
  <p><a href="https://i.stack.imgur.com/WXF5c.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WXF5c.jpg" alt="**RESULT**"></a></p>
  
  <blockquote>
    <p>The problem is how can I show it to my chartjs like this see picture below.</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/ERitk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ERitk.jpg" alt="enter image description here"></a></p>