laravel-query-builder-js 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,6 +22,12 @@ const query = new QueryBuilder()
|
|
|
22
22
|
fetch("/api/leads?" + query.toQueryParams());
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
> 💡 **Pairs perfectly with a Laravel backend.** The query params this package
|
|
26
|
+
> produces are fully compatible with [**qubuilder**](https://github.com/kalimulhaq/qubuilder)
|
|
27
|
+
> — a PHP/Laravel package that turns the same `select` / `filter` / `sort` / `include` /
|
|
28
|
+
> pagination payload into a fully-chained Eloquent query. Build the query on the client here,
|
|
29
|
+
> consume it on the server there. See [Laravel backend (qubuilder)](#laravel-backend-qubuilder).
|
|
30
|
+
|
|
25
31
|
---
|
|
26
32
|
|
|
27
33
|
## Table of contents
|
|
@@ -34,6 +40,7 @@ fetch("/api/leads?" + query.toQueryParams());
|
|
|
34
40
|
- [Vue 3](#vue-3)
|
|
35
41
|
- [Angular](#angular)
|
|
36
42
|
- [Plain fetch / Node](#plain-fetch--node)
|
|
43
|
+
- [Laravel backend (qubuilder)](#laravel-backend-qubuilder)
|
|
37
44
|
- [API reference](#api-reference)
|
|
38
45
|
- [Filtering](#filtering)
|
|
39
46
|
- [Grouped & nested conditions](#grouped--nested-conditions)
|
|
@@ -163,6 +170,44 @@ const query = new QueryBuilder().whereIn("id", [1, 2, 3]);
|
|
|
163
170
|
const res = await fetch(`https://api.example.com/users?${query.toQueryParams()}`);
|
|
164
171
|
```
|
|
165
172
|
|
|
173
|
+
## Laravel backend (qubuilder)
|
|
174
|
+
|
|
175
|
+
This package is **fully compatible** with [**qubuilder**](https://github.com/kalimulhaq/qubuilder),
|
|
176
|
+
a PHP 8.3+ / Laravel 11+ package that consumes the exact payload produced by
|
|
177
|
+
`toParams()` / `toQueryParams()` and turns it into a fully-chained Eloquent query — no manual
|
|
178
|
+
`if` chains. Together they give you an end-to-end, Laravel-style query pipeline: **compose on
|
|
179
|
+
the client with `laravel-query-builder-js`, execute on the server with qubuilder.**
|
|
180
|
+
|
|
181
|
+
The `select`, `filter`, `sort`, `include` and pagination keys map 1:1, so you don't have to
|
|
182
|
+
translate anything between the two layers.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
// Frontend — laravel-query-builder-js
|
|
186
|
+
const params = new QueryBuilder()
|
|
187
|
+
.select(["id", "firstName", "email"])
|
|
188
|
+
.where("state", "=", "Open")
|
|
189
|
+
.sort({ createdAt: "desc" })
|
|
190
|
+
.paginate(1, 25)
|
|
191
|
+
.toParams();
|
|
192
|
+
|
|
193
|
+
await fetch("/api/leads?" + new URLSearchParams(params));
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```php
|
|
197
|
+
// Backend — qubuilder (Laravel controller)
|
|
198
|
+
use Kalimulhaq\Qubuilder\Qubuilder;
|
|
199
|
+
|
|
200
|
+
public function index(GetCollectionRequest $request)
|
|
201
|
+
{
|
|
202
|
+
return Qubuilder::make($request->validated(), Lead::class)
|
|
203
|
+
->query()
|
|
204
|
+
->paginate();
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
See the [qubuilder documentation](https://github.com/kalimulhaq/qubuilder) for the full list of
|
|
209
|
+
supported operators, aggregates and configuration.
|
|
210
|
+
|
|
166
211
|
## API reference
|
|
167
212
|
|
|
168
213
|
Create a builder with the constructor or a static factory:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "laravel-query-builder-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A fluent, framework-agnostic, Laravel-style query builder for JavaScript & TypeScript. Compose select / filter / sort / include / pagination and serialise to API query params. Works in React, Vue, Angular, and Node.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"query-builder",
|