Search
 
SCRIPT & CODE EXAMPLE
 

PHP

best pagination in laravel api with eloquent

#Best Pagination for Api's in laravel using eloquent
$billerCategories = BillerCategory::select('id', 'name', 'sp_key', 'category_order', 'sp_name', 'api_id', 'address_flag')->paginate(10);
 
 return Ipay::response([
       'statusCode' => 'TXN',
       'status' => 'Biller categories fetched successfully',
          'data' => [
              'meta' => [
                    'totalPages' => $billerCategories->lastPage(),
                    'currentPage' => $billerCategories->currentPage(),
                    'totalRecords' => $billerCategories->total(),
                    'recordsOnCurrentPage' => $billerCategories->count(),
                    'recordFrom' => $billerCategories->firstItem(),
                    'recordTo' => $billerCategories->lastItem(),
                ],
                'records' => $billerCategories->items(),
            ],
        ]);
Comment

pagination in api laravel

follow this link 
https://github.com/spatie/laravel-json-api-paginate
Comment

PREVIOUS NEXT
Code Example
Php :: laravel seed fresh 
Php :: php convert mb to bytes 
Php :: laravel check if request wantsjson 
Php :: laravel route group name 
Php :: php http_build_query 
Php :: php get start of today 
Php :: name csrf token laravel mismatch 
Php :: how to format php document in vs code 
Php :: laravel route resources 
Php :: show created_at as normal date laravel blade 
Php :: laravel migration two primary key 
Php :: php curl asyc 
Php :: php get class name without namespace from string 
Php :: php trim string if longer than 
Php :: how to add property to an exsisting object in php 
Php :: carbon difference between two dates 
Php :: get full current url in laravel 
Php :: laravel new date 
Php :: laravel limit foreach 
Php :: gmdate in php 
Php :: php cli display errors 
Php :: convert image to base64 in laravel 
Php :: php show active page 
Php :: blade if 
Php :: eloquent whereraw 
Php :: php remove anchor tag from string 
Php :: clear array php 
Php :: laravel collection search by value 
Php :: db raw update laravel 
Php :: php get day number 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =