title: Foreach loop display only last record in chart of canvas and php json cannot used in javascript
body: <p>I am display sales report using canvas and i want to display sum of product sale date wise query get result but due to forecah loop i am getting last record only.I am getting four record from controller but in blade file i found only last record.</p>
  
  <p>Controller:</p>
  
  <pre><code>public function display_sales_report(Request $req)
      {
          $data=$req-&gt;all();
          $get_details=DB::select('SELECT sum(orders_qty) as sum_of_qty,deliver_date FROM `orders` WHERE deliver_date between ? AND ? GROUP BY deliver_date',[$data['start_date'],$data['end_date']]);
          return view('dashboard',['get_data'=&gt;$get_details]);
      }
  </code></pre>
  
  <p>Blade file
  :</p>
  
  <pre><code>&lt;?php
  
   $getDetails=array();
   foreach($get_data as $data)
   {
    $dataPoints = array( 
      array("y" =&gt; $data-&gt;sum_of_qty, "label" =&gt; $data-&gt;deliver_date)
      );
   }
  
  ?&gt;
   &lt;div id="chartContainer" style="height: 370px; width: 100%;"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>&lt;script&gt;
  window.onload = function() {
  
  var chart = new CanvasJS.Chart("chartContainer", {
      animationEnabled: true,
      theme: "light2",
      title:{
          text: "Sales Report"
      },
      axisY: {
          title: "Number of product sold"
      },
      data: [{
          type: "column",
          yValueFormatString: "#,##0.## tonnes",
          dataPoints: &lt;?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?&gt;
      }]
  });
  chart.render();
  
  }
  &lt;/script&gt; 
  </code></pre>