There is an error in having contiguous paging function paginate during laravel data operation. What's going on?
某草草
某草草 2017-05-16 16:49:05
0
1
874

The database data is like this:

I want to use the having statement to get out counts > 0;
uses paging, so having is followed by the paging function paginate

But this error is reported:

If I having is followed by the get() function, then there is no problem,

You can find the data of counts > 0

What's going on?

Is having followed by the paging function paginate a bug?
How to solve it?

某草草
某草草

reply all(1)
巴扎黑

paginate source code

public function paginate($perPage = 15, $columns = ['*'], $pageName = 'page', $page = null)
    {
        $page = $page ?: Paginator::resolveCurrentPage($pageName);
        $total = $this->getCountForPagination($columns);
        $results = $total ? $this->forPage($page, $perPage)->get($columns) : collect();
        return new LengthAwarePaginator($results, $total, $perPage, $page, [
            'path' => Paginator::resolveCurrentPath(),
            'pageName' => $pageName,
        ]);
    }

paginate takes the fields in the table by default, and there are no fields in the tablecounts
可换成skip($offset)->take($limit)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!