I have 3 models: User - have many Comments Article - belongs to User Comment - belongs to User, Article In user profile I would like to show all paginated actions of given user. What is best and most effective way to do it?
Asked
Active
Viewed 65 times
0
-
what is "all paginated actions"? – Pete Houston Nov 21 '14 at 18:11
-
By actions I've meant both comments and articles added by user, and paginated - returned in Paginator class with both Comment and Article classes In it. – Hubert Nov 21 '14 at 18:25
2 Answers
0
DB::table('users')
->leftJoin('comments', 'users.id', '=', 'comments.user_id')
->leftJoin('articles', 'users.id', '=', 'articles.user_id')
->paginatuse(30);

Mehrdad Hedayati
- 1,434
- 13
- 14
0
$user= new User::find(1)
->with('comments')
->with('articles')
->get();
You might not need the get() , am not sure

AlhasanIQ
- 183
- 2
- 9