An open API service indexing awesome lists of open source software.

https://github.com/victormgomes/query-params

Automatically generate query parameters based on Eloquent Models
https://github.com/victormgomes/query-params

eloquent-orm laravel parameters query query-builder

Last synced: 3 months ago
JSON representation

Automatically generate query parameters based on Eloquent Models

Awesome Lists containing this project

README

          

# Query Params

Automatically generate query parameters based on Eloquent Models

## Features

This package provides automatic rules and a builder for query parameters to be used in GET routes for index requests.
This includes rules generation and a query builder.
The available parameter operations are:

- Filters – equal, not equal, less than, and many others.
- Sorting – ascending and descending.
- Fields – fields to be included in the response.
- Includes – nested relations to be included in the response.
- Pagination – page limit and page number.

## Installation

```bash
composer require victormgomes/query-params
```

### Usage

#### Rules generation

First, use the `Rules::generate` method to inject the automatic query parameter rules into the rules of the desired class that extends a `FormRequest`.
You must also provide a fully qualified class name (FQCN) as an argument, for example:

```php
//app/Http/Requests/Users/UserIndexRequest.php
json([
'status' => 'success',
'data' => $users,
], 200);
}
...
}
```

Now you can make requests based on the generated rules.

### Many other improvements coming soon

Thanks!