Closed mouhsinelonly closed 8 years ago
There is a problem in Query.php with App::make('paginator'). in Laravel 5
I modify paginate method Like this: /* * Execute the current query and return a paginator for the results. * @param int $num * * @return \Illuminate\Pagination\LengthAwarePaginator as Paginator */ public function paginate($num = 15) { //$paginator = App::make('paginator');
$page = (int) Input::get('page', 1);
$this->limit($num, ($page - 1) * $num);
return new Paginator($this->get(), $this->count(), $this->limit, $page, [
'path' => \Request::url(),
'query' => \Request::query(),
]); //Paginator::make($this->get(), $this->count(), $num);
}
Can someone modify paginate to work with L5
Any idea when this can be merged in?
The above code didn't work for me, I ended up again my own function below to call
...
$result = self::paginate($query, $per_page = 9, $current_page);
...
}
/**
* Execute the current query and return a paginator for the results.
*
* @param $query
* @param int $num
* @param $current_page
*
* @return Paginator
*/
public static function paginate($query, $num = 15, $current_page = 1)
{
$page = (int) $current_page;
$query->limit($num, ($page - 1) * $num);
return new LengthAwarePaginator($query->get(), $query->count(), $num, $page, [
'path' => Input::url(),
'query' => Input::query(),
]);
}
https://github.com/mmanos/laravel-search/pull/43
Pull request added
This is now fixed as of the latest release (v1.0.4).
Class paginator does not exist
using laravel 5