简体   繁体   English

laravel withCount 与 count() 不起作用

[英]laravel withCount with count() not working

I want to get jobs count from the jobs table which are having at least one application.我想从至少有一个应用程序的工作表中获取工作计数。 I try with this,我试试这个,

$jobs_count = Job::withCount('allApplications')->having('all_applications_count', '>', 0)->count();

but Unknown column 'allApplications_count' error.但未知列“allApplications_count”错误。 how to fix that?如何解决? but,但,

$jobs_count = Job::withCount('allApplications')->having('all_applications_count', '>', 0)->get();

this is working.这是有效的。

you can use has :你可以使用

$jobsWithCommentsCount= Job::has('comments')->count();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM