title: passing an array from controller to js in laravel
body: <p>I'm making a morris line in my index page and I'm trying to pass data to it from my controller 
  controller:</p>
  
  <pre><code>$chartData=  DB::table('transactions')
          -&gt;select('v_type',DB::raw("MONTH(transaction_created_at)"),DB::raw('sum(v_value)'))
          -&gt;groupby('v_type',DB::raw("MONTH(transaction_created_at)"))
          -&gt;get();
  
    return view('layouts/dashboard/index', ['tickets' =&gt; $tickets , 'types'=&gt; $types,'response'=&gt;json_encode($all),'chartData' =&gt; $chartData]);
  </code></pre>
  
  <p>index.blade.php</p>
  
  <pre><code> .......&lt;div class="row clearfix"&gt;
  
                  &lt;div class="card"&gt;
  
                      &lt;div class="header"&gt;
                          &lt;h4&gt;Charts&lt;/h4&gt;
                      &lt;/div&gt;
                          &lt;div class="body"&gt;
                              &lt;div id="pushups" class="graph-wrapper" &gt; &lt;/div&gt;
  
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
    ......
   @section('extra-script')
      {{Html::script('plugins/jquery-countto/jquery.countTo.js')}}
      {{Html::script('plugins/raphael/raphael.min.js')}}
      {{Html::script('plugins/morrisjs/morris.js')}}
      {{Html::script('plugins/chartjs/Chart.bundle.js')}}
      {{Html::script('plugins/flot-charts/jquery.flot.js')}}
      {{Html::script('plugins/flot-charts/jquery.flot.resize.js')}}
      {{Html::script('plugins/flot-charts/jquery.flot.pie.js')}}
      {{Html::script('plugins/flot-charts/jquery.flot.categories.js')}}
      {{Html::script('plugins/flot-charts/jquery.flot.time.js')}}
      {{Html::script('plugins/jquery-sparkline/jquery.sparkline.js')}}
  
      {{Html::script('js/pages/index.js')}}
  
      @endsection
  </code></pre>
  
  <p>and in my index.js i have this function</p>
  
  <pre><code>function initLineChart() {
  Morris.Line({
      element: 'pushups',
      data: [
          { day: 'Monday', pushups: 20, beers: 2 },
          { day: 'Tuesday', pushups: 10, beers: 2 },
          { day: 'Wednesday', pushups: 5, beers: 3 },
          { day: 'Thursday', pushups: 5, beers: 4 },
          { day: 'Friday', pushups: 20, beers: 1 }
      ],
      xkey: 'day',
      parseTime: false,
      ykeys: ['pushups','beers'],
      labels: ['Pushups','Beers'],
      lineColors: ['#373651','#E65A26']
  });
  }
  </code></pre>
  
  <p>here I'm using this data just for testing however i would like to use the <code>$chartdata</code> to fill this morris line </p>
  
  <p>the chartdata json looks like this </p>
  
  <pre><code>[
    {
      "v_type": "money_value",
      "MONTH(transaction_created_at)": 9,
      "sum(v_value)": 15.5
    },
    {
      "v_type": "tariff_switch",
      "MONTH(transaction_created_at)": 9,
      "sum(v_value)": 3
    },
    .......]
  </code></pre>
  
  <p>so how can i do that </p>
  
  <p>Thank you in advance.</p>