laravel-pagination

Laravel pagination not working with array instead of collection

心不动则不痛 提交于 2019-11-29 08:24:24
I'm trying to paginate an array data set and it has proven more challenging than I thought. I'm using Laravel 5 So I have an abstract interface/repository that all my other models extend to and I created a method inside my abstract repository call paginate. I've included both use Illuminate\Pagination\Paginator; and use Illuminate\Pagination\LengthAwarePaginator; Here is the method public function paginate($items,$perPage,$pageStart=1) { // Start displaying items from this number; $offSet = ($pageStart * $perPage) - $perPage; // Get only the items you need using array_slice

laravel having: Column not found

扶醉桌前 提交于 2019-11-28 05:45:18
问题 my following code is like this: $places = DivePlace::selectRaw("*,(st_distance_sphere( POINT(".$lon.",".$lat.") , point(lon, lat))/1000) as distance") ->havingRaw("distance < ".$radius) ->orderBy("distance") ->paginate(10); without the "havingRaw" everything is good. After adding it, the following error came up: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance' in 'having clause' (SQL: select count(*) as aggregate from dive_places having distance < 300) Any solution? 回答1: -

Laravel pagination not working with array instead of collection

坚强是说给别人听的谎言 提交于 2019-11-28 01:41:37
问题 I'm trying to paginate an array data set and it has proven more challenging than I thought. I'm using Laravel 5 So I have an abstract interface/repository that all my other models extend to and I created a method inside my abstract repository call paginate. I've included both use Illuminate\Pagination\Paginator; and use Illuminate\Pagination\LengthAwarePaginator; Here is the method public function paginate($items,$perPage,$pageStart=1) { // Start displaying items from this number; $offSet = (

Laravel 5 - Manual pagination

淺唱寂寞╮ 提交于 2019-11-27 04:39:46
Pagination::make() method doesn't exist in Pagination class anymore in Laravel 5. Is there a workaround to make manual pagination work in Laravel 5? You need to add use: use Illuminate\Pagination\LengthAwarePaginator as Paginator; and now you can use: $paginator = new Paginator($items, $count, $limit, $page, [ 'path' => $this->request->url(), 'query' => $this->request->query(), ]); to get data in the same format as paginating on model object; Pretty way to instance this class use Illuminate\Pagination\LengthAwarePaginator as Paginator; //... $paginator = new Paginator($items->forPage($page,

Laravel 5 - Manual pagination

半城伤御伤魂 提交于 2019-11-26 11:18:12
问题 Pagination::make() method doesn\'t exist in Pagination class anymore in Laravel 5. Is there a workaround to make manual pagination work in Laravel 5? 回答1: You need to add use: use Illuminate\Pagination\LengthAwarePaginator as Paginator; and now you can use: $paginator = new Paginator($items, $count, $limit, $page, [ 'path' => $this->request->url(), 'query' => $this->request->query(), ]); to get data in the same format as paginating on model object; 回答2: Pretty way to instance this class use