从laravel控制器输出中获取仅所需的列数据的计数

时间:2018-11-01 06:10:12

标签: laravel-4

$selected_subcats2 =  EstablishmnetSubcategories::Join('establishments','establishments.id','=','establishment_subcategories.establishment_id')->where('establishment_subcategories.establishment_id',$establishment_id)->get(array('establishment_subcategories.status as status'));

Result:[{"status":0},{"status":1},{"status":1},{"status":0},{"status":0}]   

这是我的控制器条件和输出,在上面的输出中,我想获取状态计数,其值仅为零。我不想全部计数,怎么可能只获得状态零计数,请帮助...谢谢

1 个答案:

答案 0 :(得分:0)

尝试

在查询中添加where('status',0)

它将起作用