PHP code example of joshbrw / laravel-pagination-specification

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

    

joshbrw / laravel-pagination-specification example snippets


       Joshbrw\PaginationSpecification\PaginationSpecificationServiceProvider::class
    



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\View\View;
use Joshbrw\PaginationSpecification\PaginationSpecification;

class UserController extends Controller {
    public function index(
        Request $request,
        PaginationSpecification $paginationSpecification,
        UserRepository $userRepository
    ): View {
        // Reads the `per_page` and `page` values from the request
        $paginationSpecification->fromRequest($request);
        
        // Set how many items we want per page
        $paginationSpecification->setPerPage(30);
        
        // This can now be passed around to other methods, which can typehint it as a dependency
        return $userRepository->get($paginationSpecification);
    }
}
bash
    php artisan vendor:publish --provider="Joshbrw\PaginationSpecification\PaginationSpecificationServiceProvider"