Tuner Docs

A Laravel package to fine-tune your APIs.

View on GitHub
📚 Documentation
🧪 Basic Features
🧪 Intermediate Features
🧪 Advanced Features

Sort (sort[column])

The sorting feature allows clients to specify the order in which results are returned by one or more columns. This helps improve data presentation on the frontend.



Ascending Order

Request
GET /api/users?sort[name]

Where name is the column to be targeted for sorting in ascending order.


Query Parameters
Name Type Description
sort[column] string Value should be one of these: a, asc or ascending
Response
[
  {
    "id": 86,
    "name": "Arch Kessler",
    "email": "nitzsche.hellen@example.com",
    ...
  },
  {
    "id": 52,
    "name": "Aylin Runolfsson",
    "email": "schmeler.harry@example.net",
    ...
  },
  {
    "id": 1,
    "name": "Benjamin Heidenreich",
    "email": "quinton42@example.net",
    ...
  }
]


Descending Order

Request
GET /api/users?sort[id]=-

Where id is the column to be targeted and - is the indicator that data should be in descending order. Other accepted indicators: d, des, desc, descending.

Query Parameters
Name Type Description
sort[column] string Value should be one of these: -, d, des, desc or descending
Response
[
  {
    "id": 101,
    "name": "Test User",
    "email": "test@example.com",
    ...
  },
  {
    "id": 100,
    "name": "Cayla Ankunding MD",
    "email": "joey.mohr@example.com",
    ...
  },
  {
    "id": 99,
    "name": "Jan Ferry",
    "email": "sarmstrong@example.net",
    ...
  }
]