Count with Eloquent

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

Did you find this page helpful?