mardi 3 novembre 2015

How to paginate a "has many" relationship that is ordered?

I would like to paginate the following relationship (a Category having many Apps):

class Category extends Model
{
    public function apps()
    {
        return $this->hasMany('App\App')->orderBy('current_price', 'asc');
    }
}

The problem is, when I add ->paginate(10); to the end of that line, I get the following error:

Relationship method must return an object of type Illuminate\Database\Eloquent\Relations\Relation

What am I missing here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire