mercredi 18 juillet 2018

WhereHas returning if the count is greater than 2

I have a query that checks against the users table and then accesses their credential. Although, I only want to return if credential count is > 1

The relationship is a hasMany

$users = User::where('status', 1)
    ->whereHas('cred' function($q) {
        $q->where('Count('user_id') > 1')
    })->get();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire