Last active
February 20, 2016 09:33
-
-
Save jdavidbakr/d416ee4bd8454d85cff7 to your computer and use it in GitHub Desktop.
Laravel: Ajax Pagination Presenter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace App\Presenters; | |
| use Illuminate\Pagination\BootstrapThreePresenter; | |
| /** | |
| * | |
| * To use: | |
| * | |
| * $data = $query->paginate(...); // Paginate the query | |
| * $data->setPath(action(...)); // Set the page callback | |
| * $data->render(new \App\Presenters\AjaxPaginationPresenter($data)); // Render the page list | |
| * | |
| */ | |
| class AjaxPaginationPresenter extends BootstrapThreePresenter { | |
| /** | |
| * Get HTML wrapper for an available page link. | |
| * | |
| * @param string $url | |
| * @param int $page | |
| * @param string|null $rel | |
| * @return string | |
| */ | |
| protected function getAvailablePageWrapper($url, $page, $rel = null) | |
| { | |
| $rel = is_null($rel) ? '' : ' rel="'.$rel.'"'; | |
| return '<li><a href="'.htmlentities($url).'"'.$rel.' onclick="return paginate(this)">'.$page.'</a></li>'; | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment