Home>

I'm having trouble getting data. I want to do the process of skipping the next page with pagination after acquiring about 40 items in the latest order and getting 5 items on the screen.

However, I got the old 5 out of 40, and I can only get the old 5 in the latest order. If I paginate, the date is off and I can't get the data well.

More specifically, there is data from January to October this year. What I want to realize is that I want to get the latest data from October, and now I only have the latest order from February to January.

index.blade.php
$blogs = $tag->blogs ()->action ()->sort ([
        'direction' =>'DESC',
        'sort' =>'arrange'
      ])->take (5)->get ();


  
  <ul>
      {{-{{dd ($blogs)}}-}}
      @foreach ($blogs->splice (1)->sortByDesc ('release_date') as $blog)
      <li>
       slug}}/detail/{{$blog->id}} ">
      <span>{{$blog->release_date}}</span>
       {{$blog->title}} 
      <p><span>Read article</span></p>
      </li>
      @endforeach
blog.php
public function scopeSort ($query, $data = [])
    {
        foreach ($data as $key =>$val) {
            // field filter
            if (in_array ($key, $this->filterFields))
                $query->where ($key, $val);
            // field sort
            if ($key === 'sort') {
                if (! empty ($data ['direction'])) {
                    if (in_array ($data ['sort'], $this->sortFields))
                    $query->orderBy ($data ['sort'], $data ['direction']);
                }
            }
        }
        return $query;


As a supplement, the first one gets old data, and the second and subsequent ones get the latest data.

I have tried
If the contents of task (5) are changed to 40, the latest of 40 cases will come out, but 40 cases will be output and it will not work.
Also, when using sortByDesc, we get the old 5 out of 40, and we can't get the old 5 only in the latest order.

If there is any missing information, please let me know again. Thanks for your response.