take a look at https://laracasts.com/discuss/channels/laravel/is-it-paginate-available-collection it has a neat little helper function for paginating collections that might help
Jun 7, 2017
2
Level 1
Pagination on array
Hi, i need to do pagination in this query:
In Eloquent Queries i use $query->paginate(10)
But in this query i can´t because it´s an array(even after convert to object , i cant implement ->paginate or ->get():
My code:
$results = DB::select('select u.id,u.`name`,r.title, r.start_time, r.end_time, r.estado from `users` u
inner join
(select user_id, title,start_time, end_time, 4 AS estado FROM `canceled`
union all
select user_id, title,start_time, end_time, 1 AS estado FROM `events`
union all
select user_id,title, start_time, end_time, 2 AS estado FROM `confirmed`
union all
select user_id,title, start_time, end_time, 3 AS estado FROM `replaced`
union all
select user_id,title, start_time, end_time, 5 AS estado FROM `schedule`
) r on u.id = r.user_id
WHERE r.estado = 2');
$results = collect($results);
```
Please or to participate in this conversation.