我想根据数据库

时间:2016-05-29 21:50:28

标签: laravel-5.2 canvasjs

问题我有条形图当前我分配了值,我想在输入a记录时增加barchart的值与我的数据库表(id)的id值增加然后图表值增加。如何从数据库访问id的值并在视图中传递该值。有什么帮助吗?

    **Blade code**

<script type="text/javascript">
  window.onload = function () {
  var chart = new CanvasJS.Chart("chartContainer", {

  title:{
    text: "Sales Analytics"              
  },
  data: [//array of dataSeries              
    { //dataSeries object

     /*** Change type "column" to "bar", "area", "line" or "pie"***/
     type: "column",
     dataPoints: [
     { label: "orders", y: 40 },
     { label: "Bookings", y: 18 },
     { label: "Messages", y: 45 },                                    
     { label: "Products", y: 50 }

     ]
   }
   ]
   });

  chart.render();
                                                   }
</script>

  **AbcController.php**

    public function showAdmin(orders $orders){
     $data = orders::lists(['id']);
    return view('admin.orders')->with('orders', $data);
                                              }

         **Model Code**

      <?php

       namespace App;

      use Illuminate\Database\Eloquent\Model;

      class orders extends Model
     {
      protected $table = 'orders';
     }

0 个答案:

没有答案