jeudi 22 mars 2018

Sort by key in Eloquent

This is my Matrix model:

Matrix  ->   Finding   ->    Norm   ->    Normtype
          (finding_id)     (norm_id)   (normtype_id)

I'd like to fetch Matrixes, sorted by normtype.

From what I've read, orderBy only applies to keys in the actual model, such as:

public function findings() {
    return $this->hasMany('App\Finding')->orderBy('finding_id');
}

How can I do this in Eloquent?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire