[英]Call to a member function diffForHumans() on string in laravel 5.4
[英]Call to a member function count() on integer Laravel 5.4
将此添加到您的控制器
$data['count'] = your_table::where('cat_id',17)->count();
return view("YOUR_VIEW_PATH", $data);
在您的刀片模板中使用它
<div>{!! $count !!}</div>
使用sql查询
SELECT COUNT(*) from table_name where cat_id = 17
或者,如果您有像$rows = data_array
这样的查询结果,那么您可以像这样使用 php
$count = count(array_filter($rows, function($item) { return $item['cat_id'] === 17; }));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.