Answers for "pagination in api laravel"

PHP
0

none

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Collection;
use Illuminate\Pagination\LengthAwarePaginator;
  
class PaginationController extends Controller
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    public function index()
    {
        $myArray = [
            ['id'=>1, 'title'=>'Laravel 6 CRUD'],
            ['id'=>2, 'title'=>'Laravel 6 Ajax CRUD'],
            ['id'=>3, 'title'=>'Laravel 6 CORS Middleware'],
            ['id'=>4, 'title'=>'Laravel 6 Autocomplete'],
            ['id'=>5, 'title'=>'Laravel 6 Image Upload'],
            ['id'=>6, 'title'=>'Laravel 6 Ajax Request'],
            ['id'=>7, 'title'=>'Laravel 6 Multiple Image Upload'],
            ['id'=>8, 'title'=>'Laravel 6 Ckeditor'],
            ['id'=>9, 'title'=>'Laravel 6 Rest API'],
            ['id'=>10, 'title'=>'Laravel 6 Pagination'],
        ];
  
        $myCollectionObj = collect($myArray);
  
        $data = $this->paginate($myCollectionObj);
   
        return view('paginate', compact('data'));
    }
   
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    public function paginate($items, $perPage = 5, $page = null, $options = 
Posted by: Guest on January-01-1970
0

pagination in api laravel

follow this link 
https://github.com/spatie/laravel-json-api-paginate
Posted by: Guest on May-11-2021

Code answers related to "pagination in api laravel"

Browse Popular Code Answers by Language