W
W
WebDev2017-08-23 16:15:18
Laravel
WebDev, 2017-08-23 16:15:18

Laravel limit related model?

Two models Author and Article.
How to limit author's articles?

Author:find(1)->articles()->limit(10)->offset(10)->get();

This code doesn't work. How to make a limit?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rikcon, 2017-08-23
@Rikcon

Author::with(['articles' => function($query){
    $query->limit(10);
}])->find(1)->limit(10)->offset(10)->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question