Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel pagination number of items

    public function myReferals(int $user_id): array
    {
        $refer = User::query()->where('ref_id', $user_id)->select(['id', 'name', 'created_at'])
            ->paginate(20);
        $data = [];
        foreach ($refer->items() as $key => $item) {
            $number = $refer->firstItem() + $key;
            $data[] = [
                'number' => $number,
                'id'     => $item->id,
                'name'   => $item->name,
                'data'   => AdminService::parseCarbonDateFormat($item['created_at']),
            ];

        }
        $refer         = $refer->toArray();
        $refer['data'] = $data;

        return AdminService::returnSuccess([
            'status' => 'success',
            'data'   => $refer,
        ]);
    }
Comment

laravel pagination get items array

$users->items()
Comment

PREVIOUS NEXT
Code Example
Php :: Schema::defaultStringLength(199); 
Php :: php empy a file 
Php :: PHP Parses a time string according to a specified format 
Php :: enable trash for media wordpress 
Php :: filament make resource 
Php :: laravel query relationship nested 
Php :: like query with prepare wordpress 
Php :: php compress csv file 
Php :: get 2 hrs before data in php 
Php :: laravel list all tbales 
Php :: symfony auto decode json request 
Php :: laravel find model inside the same model 
Php :: recursive directory only listing php 
Php :: wc php get shipping methods 
Php :: cakephp group by count 
Php :: check date is in the last 24 hours? 
Php :: carbon now set timezone 
Php :: Uninitialized string offset 
Php :: php current page 
Php :: check url parameter if not redirect wordpress plugin 
Php :: php get day of week number 
Php :: csv file import to mysqli using php 
Php :: wp_delete_attachment unlink 
Php :: laravel index method 
Php :: laravel search and return record with pagination 
Php :: Laravel Extract Values From Collection Using Pluck() with Relationship 
Php :: php get highest value in multidimensional array 
Php :: laravel map the output of the api 
Php :: the plugin generated 14 characters of unexpected output during activation. if you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin 
Php :: if ip is 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =