Skip to content

Commit 37807a7

Browse files
authored
Merge pull request #9 from kjsoftware/issue/RDT-440
Issue/rdt 440
2 parents ecf67b3 + db7ae84 commit 37807a7

34 files changed

+1092
-199
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
* text eol=lf
55

66
# Ignore all test and documentation with "export-ignore".
7+
/.github export-ignore
78
/.gitattributes export-ignore
89
/.gitignore export-ignore
910
/.travis.yml export-ignore
1011
/phpunit.xml.dist export-ignore
12+
/.php_cs.dist.php export-ignore
1113
/.scrutinizer.yml export-ignore
1214
/tests export-ignore
1315
/.editorconfig export-ignore

.github/workflows/dependabot-auto-merge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- name: Dependabot metadata
1515
id: metadata
16-
uses: dependabot/fetch-metadata@v2.1.0
16+
uses: dependabot/fetch-metadata@v2.4.0
1717
with:
1818
github-token: "${{ secrets.GITHUB_TOKEN }}"
1919
compat-lookup: true

.github/workflows/run-tests.yml

Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,73 @@
11
name: run-tests
22

33
on:
4-
push:
5-
paths:
6-
- '**.php'
7-
- '.github/workflows/run-tests.yml'
8-
- 'phpunit.xml.dist'
9-
- 'composer.json'
10-
- 'composer.lock'
4+
push
115

126
jobs:
13-
test:
14-
runs-on: ${{ matrix.os }}
15-
timeout-minutes: 5
16-
strategy:
17-
fail-fast: true
18-
matrix:
19-
os: [ubuntu-latest]
20-
php: [8.3, 8.2]
21-
laravel: [10.*, 11.*]
22-
stability: [prefer-stable]
23-
include:
24-
- laravel: 11.*
25-
testbench: 9.*
26-
carbon: ^2.63
27-
- laravel: 10.*
28-
testbench: 8.*
7+
test:
8+
runs-on: ${{ matrix.os }}
299

30-
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
10+
timeout-minutes: 5
3111

32-
services:
33-
mysql:
34-
image: mysql:8.0
35-
env:
36-
MYSQL_USER: user
37-
MYSQL_PASSWORD: secret
38-
MYSQL_DATABASE: laravel_query_builder
39-
MYSQL_ROOT_PASSWORD: secretroot
40-
ports:
41-
- 3306
42-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
12+
strategy:
13+
fail-fast: true
14+
matrix:
15+
os: [ubuntu-latest]
16+
php: [8.4, 8.3, 8.2]
17+
laravel: ['10.*', '11.*', '12.*']
18+
stability: [prefer-stable]
19+
include:
20+
- laravel: 11.*
21+
testbench: 9.*
22+
- laravel: 10.*
23+
testbench: 8.*
24+
- laravel: 12.*
25+
testbench: 10.*
4326

44-
redis:
45-
image: redis
46-
ports:
47-
- 6379:6379
48-
options: >-
49-
--health-cmd "redis-cli ping"
50-
--health-interval 10s
51-
--health-timeout 5s
52-
--health-retries 5
27+
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
5328

54-
steps:
55-
- name: Checkout code
56-
uses: actions/checkout@v4
29+
services:
30+
mysql:
31+
image: mysql:8.0
32+
env:
33+
MYSQL_USER: user
34+
MYSQL_PASSWORD: secret
35+
MYSQL_DATABASE: laravel_query_builder
36+
MYSQL_ROOT_PASSWORD: secretroot
37+
ports:
38+
- 3306
39+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
40+
redis:
41+
image: redis
42+
ports:
43+
- 6379:6379
44+
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
5745

58-
- name: Setup PHP
59-
uses: shivammathur/setup-php@v2
60-
with:
61-
php-version: ${{ matrix.php }}
62-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
63-
coverage: none
46+
steps:
47+
- name: Checkout code
48+
uses: actions/checkout@v4
6449

65-
- name: Setup problem matchers
66-
run: |
67-
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
68-
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
50+
- name: Setup PHP
51+
uses: shivammathur/setup-php@v2
52+
with:
53+
php-version: ${{ matrix.php }}
54+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
55+
coverage: none
6956

70-
- name: Install dependencies
71-
run: |
72-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
73-
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
57+
- name: Setup problem matchers
58+
run: |
59+
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
60+
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
7461
75-
- name: Execute tests
76-
run: vendor/bin/pest
77-
env:
78-
DB_USERNAME: user
79-
DB_PASSWORD: secret
80-
DB_PORT: ${{ job.services.mysql.ports[3306] }}
81-
REDIS_PORT: 6379
62+
- name: Install dependencies
63+
run: |
64+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
65+
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
8266
67+
- name: Execute tests
68+
run: vendor/bin/pest
69+
env:
70+
DB_USERNAME: user
71+
DB_PASSWORD: secret
72+
DB_PORT: ${{ job.services.mysql.ports[3306] }}
73+
REDIS_PORT: 6379

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ composer.lock
33
vendor
44
.php_cs.cache
55
coverage
6+
.phpunit.cache
67
.phpunit.result.cache
78
/.idea
89
.php-cs-fixer.cache
9-

.phpunit.cache/test-results

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,118 @@
22

33
All notable changes to `laravel-query-builder` will be documented in this file
44

5+
## 6.3.2 - 2025-04-16
6+
7+
### What's Changed
8+
9+
* Enhance QueryBuilder with generics support for better type inference by @alexkart in https://github.com/spatie/laravel-query-builder/pull/1002
10+
11+
### New Contributors
12+
13+
* @alexkart made their first contribution in https://github.com/spatie/laravel-query-builder/pull/1002
14+
15+
**Full Changelog**: https://github.com/spatie/laravel-query-builder/compare/6.3.1...6.3.2
16+
17+
## 6.3.1 - 2025-02-21
18+
19+
### What's Changed
20+
21+
* General code health improvements by @xHeaven in https://github.com/spatie/laravel-query-builder/pull/988
22+
* Bump dependabot/fetch-metadata from 2.2.0 to 2.3.0 by @dependabot in https://github.com/spatie/laravel-query-builder/pull/992
23+
* Laravel 12.x Compatibility by @laravel-shift in https://github.com/spatie/laravel-query-builder/pull/994
24+
* Exclude `.github` folder and `.php_cs` from being included in composer installation by @stevebauman in https://github.com/spatie/laravel-query-builder/pull/993
25+
26+
### New Contributors
27+
28+
* @xHeaven made their first contribution in https://github.com/spatie/laravel-query-builder/pull/988
29+
30+
**Full Changelog**: https://github.com/spatie/laravel-query-builder/compare/6.3.0...6.3.1
31+
32+
## 6.3.0 - 2024-12-23
33+
34+
### What's Changed
35+
36+
* Feature: Add "belongs to" filter by @gpibarra in https://github.com/spatie/laravel-query-builder/pull/975
37+
* Feature: Additional config options to better match the API spec by @CoolGoose in https://github.com/spatie/laravel-query-builder/pull/983
38+
39+
### New Contributors
40+
41+
* @CoolGoose made their first contribution in https://github.com/spatie/laravel-query-builder/pull/983
42+
43+
**Full Changelog**: https://github.com/spatie/laravel-query-builder/compare/6.2.3...6.3.0
44+
45+
## 6.2.3 - 2024-12-23
46+
47+
### What's Changed
48+
49+
* Fix selecting fields on belongs to many relations by @rasmuscnielsen in https://github.com/spatie/laravel-query-builder/pull/986
50+
51+
### New Contributors
52+
53+
* @rasmuscnielsen made their first contribution in https://github.com/spatie/laravel-query-builder/pull/986
54+
55+
**Full Changelog**: https://github.com/spatie/laravel-query-builder/compare/6.2.2...6.2.3
56+
57+
## 6.2.2 - 2024-12-11
58+
59+
### What's Changed
60+
61+
* Update filtering.md to clarify handling of array scope parameter by @g-gullstrand in https://github.com/spatie/laravel-query-builder/pull/976
62+
* Remove PHPUnit cache by @tarexme in https://github.com/spatie/laravel-query-builder/pull/982
63+
* Fix typo in filtering.md by @yngc0der in https://github.com/spatie/laravel-query-builder/pull/984
64+
* Fixed IncludedCount.php by @dash8x in https://github.com/spatie/laravel-query-builder/pull/978
65+
66+
### New Contributors
67+
68+
* @g-gullstrand made their first contribution in https://github.com/spatie/laravel-query-builder/pull/976
69+
* @tarexme made their first contribution in https://github.com/spatie/laravel-query-builder/pull/982
70+
* @yngc0der made their first contribution in https://github.com/spatie/laravel-query-builder/pull/984
71+
* @dash8x made their first contribution in https://github.com/spatie/laravel-query-builder/pull/978
72+
73+
**Full Changelog**: https://github.com/spatie/laravel-query-builder/compare/6.2.1...6.2.2
74+
75+
## 6.2.1 - 2024-10-03
76+
77+
### What's Changed
78+
79+
* Removed explicit escaping for `pgsql` driver in `FiltersPartial` - Fixes #941 by @Talpx1 in https://github.com/spatie/laravel-query-builder/pull/968
80+
81+
**Full Changelog**: https://github.com/spatie/laravel-query-builder/compare/6.2.0...6.2.1
82+
83+
## 6.2.0 - 2024-09-27
84+
85+
### What's Changed
86+
87+
* [FEAT] add filter by operator by @AbdelrahmanBl in https://github.com/spatie/laravel-query-builder/pull/940
88+
* Add documentation for the operator filter by @AlexVanderbist in https://github.com/spatie/laravel-query-builder/pull/974
89+
90+
### New Contributors
91+
92+
* @AbdelrahmanBl made their first contribution in https://github.com/spatie/laravel-query-builder/pull/940
93+
94+
**Full Changelog**: https://github.com/spatie/laravel-query-builder/compare/6.1.0...6.2.0
95+
96+
## 6.1.0 - 2024-09-23
97+
98+
### What's Changed
99+
100+
* Bump ramsey/composer-install from 2 to 3 by @dependabot in https://github.com/spatie/laravel-query-builder/pull/939
101+
* Add issue #175 link in selecting-fields.md by @alipadron in https://github.com/spatie/laravel-query-builder/pull/951
102+
* Update filtering.md by @justinkekeocha in https://github.com/spatie/laravel-query-builder/pull/954
103+
* Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0 by @dependabot in https://github.com/spatie/laravel-query-builder/pull/955
104+
* [DOCS] Update Frontend implementation with a new one by @cgarciagarcia in https://github.com/spatie/laravel-query-builder/pull/961
105+
* Update Documentation for php markdown by @chengkangzai in https://github.com/spatie/laravel-query-builder/pull/969
106+
* AllowedFilter should return static rather than self by @kosarinin in https://github.com/spatie/laravel-query-builder/pull/964
107+
108+
### New Contributors
109+
110+
* @alipadron made their first contribution in https://github.com/spatie/laravel-query-builder/pull/951
111+
* @cgarciagarcia made their first contribution in https://github.com/spatie/laravel-query-builder/pull/961
112+
* @chengkangzai made their first contribution in https://github.com/spatie/laravel-query-builder/pull/969
113+
* @kosarinin made their first contribution in https://github.com/spatie/laravel-query-builder/pull/964
114+
115+
**Full Changelog**: https://github.com/spatie/laravel-query-builder/compare/6.0.1...6.1.0
116+
5117
## 6.0.1 - 2024-05-21
6118

7119
### What's Changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
# Build Eloquent queries from API requests
1+
<div align="left">
2+
<a href="https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=laravel-query-builder">
3+
<picture>
4+
<source media="(prefers-color-scheme: dark)" srcset="https://spatie.be/packages/header/laravel-query-builder/html/dark.webp">
5+
<img alt="Logo for laravel-query-builder" src="https://spatie.be/packages/header/laravel-query-builder/html/light.webp" height="190">
6+
</picture>
7+
</a>
8+
9+
<h1>Build Eloquent queries from API requests</h1>
210

311
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-query-builder.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-query-builder)
412
![Test Status](https://img.shields.io/github/actions/workflow/status/spatie/laravel-query-builder/run-tests.yml?label=tests&branch=main)
513
![Code Style Status](https://img.shields.io/github/actions/workflow/status/spatie/laravel-query-builder/php-cs-fixer.yml?label=code%20style&branch=main)
614
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-query-builder.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-query-builder)
7-
8-
This package allows you to filter, sort and include eloquent relations based on a request. The `QueryBuilder` used in this package extends Laravel's default Eloquent builder. This means all your favorite methods and macros are still available. Query parameter names follow the [JSON API specification](http://jsonapi.org/) as closely as possible.
15+
16+
</div>
917

1018
## Caching foreign keys
1119
Add this line to your composer.json file to cache foreign keys. This will allow the query builder to automatically detect foreign keys without having to make a database call.

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@
2121
],
2222
"require": {
2323
"php": "^8.2",
24-
"illuminate/database": "^10.0|^11.0",
25-
"illuminate/http": "^10.0|^11.0",
26-
"illuminate/support": "^10.0|^11.0",
24+
"illuminate/database": "^10.0|^11.0|^12.0",
25+
"illuminate/http": "^10.0|^11.0|^12.0",
26+
"illuminate/support": "^10.0|^11.0|^12.0",
2727
"spatie/laravel-package-tools": "^1.11",
2828
"doctrine/dbal": "^3.5"
2929
},
3030
"require-dev": {
3131
"ext-json": "*",
3232
"mockery/mockery": "^1.4",
33-
"nunomaduro/larastan": "^2.0",
34-
"orchestra/testbench": "^7.0|^8.0",
35-
"phpunit/phpunit": "^10.0",
36-
"pestphp/pest": "^2.0",
33+
"orchestra/testbench": "^7.0|^8.0|^10.0",
34+
"pestphp/pest": "^2.0|^3.7",
35+
"phpunit/phpunit": "^10.0|^11.5.3",
3736
"spatie/invade": "^2.0"
3837
},
3938
"autoload": {

config/query-builder.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,23 @@
6060
* GET /users?fields[userOwner]=id,name
6161
*/
6262
'convert_relation_names_to_snake_case_plural' => true,
63+
64+
/*
65+
* By default, the package expects relationship names to be snake case plural when using fields[relationship].
66+
* For example, fetching the id and name for a userOwner relation would look like this:
67+
* GET /users?fields[user_owner]=id,name
68+
*
69+
* Set this to one of `snake_case`, `camelCase` or `none` if you want to enable table name resolution in addition to the relation name resolution
70+
* GET /users?include=topOrders&fields[orders]=id,name
71+
*/
72+
'convert_relation_table_name_strategy' => false,
73+
74+
/*
75+
* By default, the package expects the field names to match the database names
76+
* For example, fetching the field named firstName would look like this:
77+
* GET /users?fields=firstName
78+
*
79+
* Set this to `true` if you want to convert the firstName into first_name for the underlying query
80+
*/
81+
'convert_field_names_to_snake_case' => false,
6382
];

database/factories/AppendModelFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Spatie\QueryBuilder\Database\Factories;
44

5-
use Spatie\QueryBuilder\Tests\TestClasses\Models\AppendModel;
65
use Illuminate\Database\Eloquent\Factories\Factory;
6+
use Spatie\QueryBuilder\Tests\TestClasses\Models\AppendModel;
77

88
class AppendModelFactory extends Factory
99
{

0 commit comments

Comments
 (0)