Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

syofyanzuhad's avatar

Laravel Pagination Numbering API

How can i return the item number of the resource in API with pagination?

i use the paginate() function as usual

my json now is like this:

{
    "success": true,
    "status": "success",
    "message": "Karyawan berhasil ditampilkan",
    "data": {
        "current_page": 1,
        "data": [
            {
                "id": 1,
                "foto": null,
                "nik": "292680381382302",
                "nama": "Admin",
            }
        ],
        "first_page_url": "http://pmo-9.test/api/karyawan?page=1",
        "from": 1,
        "last_page": 1,
        "last_page_url": "http://pmo-9.test/api/karyawan?page=1",
        "links": [
            {
                "url": null,
                "label": "« Previous",
                "active": false
            },
            {
                "url": "http://pmo-9.test/api/karyawan?page=1",
                "label": "1",
                "active": true
            },
            {
                "url": null,
                "label": "Next »",
                "active": false
            }
        ],
        "next_page_url": null,
        "path": "http://pmo-9.test/api/karyawan",
        "per_page": "5",
        "prev_page_url": null,
        "to": 1,
        "total": 1
    }
}

how can I add the number: 1 column to the response?

0 likes
0 replies

Please or to participate in this conversation.