Search
 
SCRIPT & CODE EXAMPLE
 

PHP

forPage return keys on page 2

// On pages >= 2, the keys are returned since forPage returns an array with keys
// To fix this, just chain values() method.
$items_per_page = 10;
$current_page = LengthAwarePaginator::resolveCurrentPage();
$paginated_response = new LengthAwarePaginator(
  	collect($items)->forPage($current_page, $items_per_page)->values(),
  	count($items),
  	$items_per_page,
  	$current_page,
  	['path' => url('api/portfolios')]
);
return response()->json($paginated_response);
Comment

PREVIOUS NEXT
Code Example
Php :: ubuntu add phpstorm to launcher 
Php :: Who developed Laravel? 
Php :: how to get count of rows in a table in laravel query 
Php :: php detect daylight saving time 
Php :: php decrement variable by 1 
Php :: fprintf (PHP 5, PHP 7, PHP 8) fprintf — Write a formatted string to a stream 
Php :: Dein Benutzer-Profil um weitere Social Media Accounts erweitern 
Php :: php get list of months by year 
Php :: php check if variable is true or false 
Php :: laravel foreach localstorage 
Php :: docker php-fpm 
Php :: how to link a external modules using href in php 
Php :: cmd download file from url 
Php :: php pasar array por post 
Php :: http://www.endmemo.com/program/R/vector.php 
Php :: larave per page int returns string 
Php :: Button in Laravel Datatable not rendering 
Php :: accessing class in php 
Php :: : in php 
Php :: htmlentities (PHP 4, PHP 5, PHP 7, PHP 8) htmlentities — Convert all applicable characters to HTML entities 
Php :: Required parameter follows optional parameter (500 Internal Server Error) php 
Php :: symfony how to respond in-memory file 
Php :: Yii2: Setting default values for all attributes of a model 
Php :: wp clean db terms 
Php :: unexpected variable 
Php :: verifier la version de php sur mon ordi 
Php :: set additional params to form laravel 
Php :: namespace autoload php 
Php :: hirudhi 
Php :: wp_signon wordpress login subdomain 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =