Skip to content

Commit a3bed78

Browse files
authored
Support for Laravel 9 (#53)
1 parent 01b0148 commit a3bed78

File tree

5 files changed

+43
-36
lines changed

5 files changed

+43
-36
lines changed

.github/workflows/run-tests.yml

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ jobs:
99
fail-fast: true
1010
matrix:
1111
php: [8.1, 8.0]
12-
laravel: [8.*]
12+
laravel: [9.*, 8.*]
1313
dependency-version: [prefer-lowest, prefer-stable]
1414
include:
15-
- laravel: 8.*
16-
testbench: 6.*
15+
- laravel: 9.*
16+
testbench: 7.*
17+
- laravel: 8.*
18+
testbench: 6.*
1719

1820
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
1921

@@ -30,33 +32,32 @@ jobs:
3032
- 3306
3133
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
3234

33-
3435
steps:
35-
- name: Checkout code
36-
uses: actions/checkout@v2
37-
38-
- name: Cache dependencies
39-
uses: actions/cache@v2
40-
with:
41-
path: ~/.composer/cache/files
42-
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
43-
44-
- name: Setup PHP
45-
uses: shivammathur/setup-php@v2
46-
with:
47-
php-version: ${{ matrix.php }}
48-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql
49-
coverage: none
50-
51-
- name: Install dependencies
52-
run: |
53-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
54-
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
55-
56-
- name: Execute tests
57-
run: vendor/bin/phpunit
58-
env:
59-
DB_DATABASE: protone_media_db_test
60-
DB_USERNAME: protone_media_db_test
61-
DB_PASSWORD: secret
62-
DB_PORT: ${{ job.services.mysql.ports[3306] }}
36+
- name: Checkout code
37+
uses: actions/checkout@v2
38+
39+
- name: Cache dependencies
40+
uses: actions/cache@v2
41+
with:
42+
path: ~/.composer/cache/files
43+
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
44+
45+
- name: Setup PHP
46+
uses: shivammathur/setup-php@v2
47+
with:
48+
php-version: ${{ matrix.php }}
49+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql
50+
coverage: none
51+
52+
- name: Install dependencies
53+
run: |
54+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
55+
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
56+
57+
- name: Execute tests
58+
run: vendor/bin/phpunit
59+
env:
60+
DB_DATABASE: protone_media_db_test
61+
DB_USERNAME: protone_media_db_test
62+
DB_PASSWORD: secret
63+
DB_PORT: ${{ job.services.mysql.ports[3306] }}

CHANGELOG.md

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

33
All notable changes to `laravel-cross-eloquent-search` will be documented in this file
44

5+
## 2.7.0 - 2022-02-04
6+
7+
- Support for Laravel 9
8+
59
## 2.6.1 - 2021-12-22
610

711
- Bugfix for excluding models when searching for relations without a search term (fixes #37).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Hey! We've built a Docker-based deployment tool to launch apps and sites fully c
1515

1616
* PHP 8.0 + 8.1
1717
* MySQL 5.7+
18-
* Laravel 8.0
18+
* Laravel 8.0 or 9.0
1919

2020
## Features
2121

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
],
1818
"require": {
1919
"php": "^8.0|^8.1",
20-
"illuminate/support": "^8.79"
20+
"illuminate/support": "^8.79|^9.0"
2121
},
2222
"require-dev": {
2323
"mockery/mockery": "^1.3.3",
24-
"orchestra/testbench": "^6.23",
24+
"orchestra/testbench": "^6.23|^7.0",
2525
"phpunit/phpunit": "^9.4"
2626
},
2727
"autoload": {

src/Searcher.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,12 @@ public function simplePaginate($perPage = 15, $pageName = 'page', $page = null):
370370
*/
371371
public function parseTerms(string $terms, callable $callback = null): Collection
372372
{
373+
$callback = $callback ?: fn () => null;
374+
373375
return Collection::make(str_getcsv($terms, ' ', '"'))
374376
->filter()
375377
->values()
376-
->when($callback, function ($terms, $callback) {
378+
->when($callback !== null, function ($terms) use ($callback) {
377379
return $terms->each(fn ($value, $key) => $callback($value, $key));
378380
});
379381
}

0 commit comments

Comments
 (0)