noblemfd
1 week ago
157
10
Laravel

Laravel Query not giving expected result

Posted 1 week ago by noblemfd

I want to count the number of employees that have published their goals and groupby employee_id where is_published is 1.

$testing = Goal::where('is_published', 1)->where('company_id', $userCompany)->groupBy('employee_id')->count();

From the table I have four (4) rows but the same employee_id, I expected to get 1 but I am getting 4?

dd($testing) gives me 4

How do I achieve this?

Thanks

Please sign in or create an account to participate in this conversation.