PHP code example of michaloravec / laravel-paginateroute

1. Go to this page and download the library: Download michaloravec/laravel-paginateroute 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/ */

    

michaloravec / laravel-paginateroute example snippets




return [

    /*
    |--------------------------------------------------------------------------
    | Paginate Mode
    |--------------------------------------------------------------------------
    |
    | This option controls the default mode that will be used to paginate
    | route for your application. By default, the normal mode is used;
    | however, you remain free to modify this option if you wish.
    |
    | Supported: "normal", "dash", "simple"
    |
    */

    'mode' => 'normal',

];

// app/Providers/RouteServiceProvider.php

use PaginateRoute;

// ...

public function boot()
{
    PaginateRoute::registerMacros();

    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)]);
}

/**
 * @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)

/**
 * @return int|null
 */
public function previousPage()

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

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

/**
 * @param int  $page
 * @param bool $full
 * @return string
 */
public function pageUrl($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  string $class
 * @param  bool $additionalLinks
 * @return string
 */
public function renderPageList(LengthAwarePaginator $paginator, $full = false, $class = 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=MichalOravec\PaginateRoute\PaginateRouteServiceProvider --tag="config"