我对拉威尔有意见。我想用雄辩的方式显示百分比,但返回空值
这是我的控制器
$group_categories = Proyek::with(['modul' => function($query){
$query->select(DB::raw('((select count(*) from modul where status = 0 and deleted_at IS NULL) /
(select count(*) from modul where deleted_at IS NULL)) *
100 as count' ));
}])->get();
这是json返回
{
id: "10",
proyek: "JuZka",
created_at: "2018-08-12 01:54:04",
updated_at: "2018-09-23 05:49:13",
modul: [ ]
},
1条答案
按热度按时间7kjnsjlb1#
您可以使用如下代码: