Count with Eloquent

I have a "project" table and I want to count projects by status. Any solution please?
3 Replies
Np
Np12mo ago
$projectCounts = Project::select('status', DB::raw('COUNT(*) as project_count')) ->groupBy('status') ->get(); @Abdulla Fahem
ChesterS
ChesterS12mo ago
https://filamentphp.com/docs/3.x/tables/summaries#count You can also do something like Project::groupBy('status')->count()
abdullafahem
abdullafahemOP12mo ago
Thanks Thanks
Want results from more Discord servers?
Add your server