我想计算使用以下代码获得的输出:
Blade View
{{ $kentekens->where('created_at', '>=', Carbon::today()) }}
这给出了字符串输出,但我想计算它获得的匹配数量。 我尝试了以下方法但没有成功:
{{ $kentekens->where('created_at', '>=', Carbon::today()->count()) }}
{{ $kentekens->count()->where('created_at', '>=', Carbon::today()) }}
Controller
public function create() {
$kentekens = Kenteken::latest()
->get();
return view('layouts.dashboard', compact('kentekens'));
}
型号
class Kenteken extends Model {
protected $table = "kenteken";
}
有人有什么想法吗?
最佳答案
正确的语法是:
{{ $kentekens->where('created_at', '>=', Carbon::today())->count() }}
关于php - 如何在使用 Carbon 在 Laravel/Eloquent 中使用 'count' 时出现 'where',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48389940/