mardi 29 août 2017

Laravel 5.4 - group by, count and join

I have two tables (models have the same name as the tables):

StatusNames: id|name

and

CurrentUserStatus: id|user_id|status_id

At the moment CurrentUserStatus is empty, and StatusNames have several records inserted (Active, Inactive, On Pause, Terminated...).

I need to get all data from CurrentUserStatus and show how much are there within each status (given the current tables, next to each status name there should be zero (0)).

Is this possible to do with one query?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire