分页下一步按钮在laravel上不起作用

20jt8wwn  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(201)

我做错了什么?分页不起作用,我没有收到任何错误。“下一步”按钮不起作用。有解决办法吗?

class PostsIndex extends Component

    public function render()
    {
        $statuses = Status::all()->pluck('id', 'name');
        $schools = School::all();

        return view('livewire.posts-index', [
            'posts' => Post::with('user', 'school', 'status')
            ->when($this->status && $this->status !== 'All', function ($query) use ($statuses) {
                return $query->where('status_id', $statuses->get($this->status));
            })->when($this->school && $this->school !== 'All Schools', function ($query) use ($schools) {
                return $query->where('school_id', $schools->pluck('id', 'name')->get($this->school));
            })->when($this->filter && $this->filter === 'Top Exp', function ($query) {
                return $query->orderByDesc('votes_count');
            })->when($this->filter && $this->filter === 'My Exp', function ($query) {
                return $query->where('user_id', auth()->id());
            })->when($this->filter && $this->filter === 'Spam Posts', function ($query) {
                return $query->where('spam_reports', '>', 0)->orderByDesc('spam_reports');

            })->when(strlen($this->search) >= 3, function ($query) {
                return $query->where('body', 'like', '%'.$this->search.'%');
            })
                ->addSelect(['voted_by_user' => Vote::select('id')
                    ->where('user_id', auth()->id())
                    ->whereColumn('post_id', 'posts.id')
                ])
                ->withCount('votes')
                ->withCount('comments')
                ->orderBy('id', 'desc')
                ->simplePaginate(10)
                ->withQueryString(),
                'schools' => $schools,
        ]);
    }
}

我已经尽了最大的努力,但还是没能使它发挥作用

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题