PHP code example of web-ruslan / laravel-pretty-pagination

1. Go to this page and download the library: Download web-ruslan/laravel-pretty-pagination library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

web-ruslan / laravel-pretty-pagination example snippets


// config/app.php

'providers' => [
    ...
    'WebRuslan\PaginateRoute\PaginateRouteServiceProvider',
];

'aliases' => [
    ...
    'PaginateRoute' => 'WebRuslan\PaginateRoute\PaginateRouteFacade',
];

// app/Providers/RouteServiceProvider.php

use WebRuslan\PaginateRoute\PaginateRouteFacade as PaginateRoute;

// ...

public function boot()
{
    PaginateRoute::registerMacros(); // Add this line

    parent::boot();
}

// app/Http/routes.php

// Generates /users & /users/page/{page}
Route::paginate('users', 'UsersController@index');


// app/Http/Controllers/UsersController.php

public function index()
{
    return view('users.index', ['users' => \App\User::simplePaginate(5)]);
}

public function index()
{
    $users = \App\User::simplePaginate(5);
    $users->setPath('custom/url');
    return view('users.index', ['users' => $users]);
}

/**
 * @param  \Illuminate\Contracts\Pagination\Paginator $paginator
 * @return int|null
 */
public function nextPage(Paginator $paginator)

/**
 * @param  \Illuminate\Contracts\Pagination\Paginator $paginator
 * @return bool
 */
public function hasNextPage(Paginator $paginator)

/**
 * @param  \Illuminate\Contracts\Pagination\Paginator $paginator
 * @return string|null
 */
public function nextPageUrl(Paginator $paginator)

/**
 * @param  \Illuminate\Contracts\Pagination\Paginator $paginator
 * @return int|null
 */
public function previousPage(Paginator $paginator)

/**
 * @return bool
 */
public function hasPreviousPage()

/**
 * @param  bool $full
 * @return string|null
 */
public function previousPageUrl($full = false)

/**
 * @param  \Illuminate\Contracts\Pagination\Paginator $paginator
 * @param int  $page
 * @param bool $full
 * @return string
 */
public function pageUrl(Paginator $paginator, $page, $full = false)

/**
 * @param string $url
 * @param int $page
 * @param bool $full
 * @return string
 */
public function addPageQuery($url, $page, $full = false)

/**
 * @param  \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
 * @param  bool $full
 * @return array
 */
public function allUrls(LengthAwarePaginator $paginator, $full = false)

/**
 * @param  \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
 * @param  bool $full
 * @param  array $styles
 * @param  bool $additionalLinks
 * @return string
 */
public function renderPageList(LengthAwarePaginator $paginator, $full = false, $styles = null, $additionalLinks = false)


/**
 * @param  \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
 * @param  bool $full
 * @return string
 */
public function renderRelLinks(LengthAwarePaginator $paginator, $full = false)
 bash
php artisan vendor:publish --provider="WebRuslan\PaginateRoute\PaginateRouteServiceProvider"