samedi 16 novembre 2019

How to use orderBy with count method

Corral model:

public function sheeps()
{
    return $this->hasMany('App\Sheep');
}

I want to order by number of sheep in each corral and get corral with fewest sheep number:

$corral = Corral::orderBy(..., 'ASC')->first();


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire