Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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,
        ]);
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #pagination #number #items
ADD COMMENT
Topic
Name
2+4 =