bestmomo / laravel5-example

Simple laravel5 example for tutorial

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

latest or oldest

amin101 opened this issue · comments

commented

I'm a bit confused by using latest and oldest methods in same query . would you please explain this :

public function index($n)
    {
        return $this->model
        ->with('post', 'user')
        ->oldest('seen')
        ->latest()
        ->paginate($n);
    }

Because there are 2 orders, look at queries :

select count(*) as aggregate from `comments`
select * from `comments` order by `seen` asc, `created_at` desc limit 4 offset 0
select * from `posts` where `posts`.`id` in ('1', '2')
select * from `users` where `users`.`id` in ('2', '3')
select * from `users` where `users`.`id` = '1' limit 1