如何调用查询到脚本部分

问题描述

我有数据库调用数据的查询,以及如何将查询调用到blade.PHP 的脚本部分?

仪表板控制器:

 $list_state = DB::table('ref_state')
        ->where('status_state',1)
        ->get();

foreach ($list_state as $list_state) {
        $total_people = DB::table('tbl_people')
            ->join('tbl_people_flood','tbl_people.id_people','=','tbl_people_flood.id_people')
            ->where('tbl_people_flood.id_people',1)
            ->where('status_people',1)
            ->where('id_state',$list_state->id_state)
            ->count();
        $people[] = $total_people;
    }

return view('dashboard.administrator',[
        'list_state' => $list_state,'people' => $people,]);

数据显示 $list_state = ["Tokyo","Helsinki","London"] 和 $people = [1000,6522,700]

dashboard.blade.PHP :

@section('scripts')
<script>
am4core.ready(function() {

    am4core.useTheme(am4themes_animated);

    var chart = am4core.create("chartdiv",am4charts.XYChart);

    chart.exporting.menu = new am4core.ExportMenu();

    var data = [{
        "city": "TOKYO","income": 483,"expenses": 700
    },{
        "city": "HELSINKI","income": 1357,"expenses": 1000
    }];

    var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
    categoryAxis.datafields.category = "city";
    categoryAxis.renderer.minGriddistance = 30;

    var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());

    var columnSeries = chart.series.push(new am4charts.ColumnSeries());
    columnSeries.datafields.valueY = "income";
    columnSeries.datafields.categoryX = "city";
 }); // end am4core.ready()

</script>

我想将查询调用到数据变量和城市作为 $list_state 和收入作为 $people.. 谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...