PHP code example of camohub / paginator

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

    

camohub / paginator example snippets


$paginator = new Paginator($request, $category->articles(), 'articles', ['categorySlug' => $categorySlug]);
$php
public function index(Request $request, $categorySlug, $page = 1)
{
    $category = Category::where('slug', $categorySlug)->first()
    
    if( ! $category ) abort(404);
    
    $paginator = new Paginator($request, $category->articles(), 'articles', ['categorySlug' => $categorySlug]);

    $view = [
        'articles' => $paginator->getItems(),
        'paginator' => $paginator,
        'category' => $category,
    ];

    return view('articles.index', $view);
}
$php
$this->items = $this->model->skip($this->skip)->take($this->perPage)->get();