Skip to content

Commit

Permalink
Support for Laravel 9 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalbaljet committed Feb 4, 2022
1 parent 01b0148 commit a3bed78
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
65 changes: 33 additions & 32 deletions .github/workflows/run-tests.yml
Expand Up @@ -9,11 +9,13 @@ jobs:
fail-fast: true
matrix:
php: [8.1, 8.0]
laravel: [8.*]
laravel: [9.*, 8.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 9.*
testbench: 7.*
- laravel: 8.*
testbench: 6.*

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

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


steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit
env:
DB_DATABASE: protone_media_db_test
DB_USERNAME: protone_media_db_test
DB_PASSWORD: secret
DB_PORT: ${{ job.services.mysql.ports[3306] }}
- name: Checkout code
uses: actions/checkout@v2

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, mysql, mysqli, pdo_mysql
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
- name: Execute tests
run: vendor/bin/phpunit
env:
DB_DATABASE: protone_media_db_test
DB_USERNAME: protone_media_db_test
DB_PASSWORD: secret
DB_PORT: ${{ job.services.mysql.ports[3306] }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

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

## 2.7.0 - 2022-02-04

- Support for Laravel 9

## 2.6.1 - 2021-12-22

- Bugfix for excluding models when searching for relations without a search term (fixes #37).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -15,7 +15,7 @@ Hey! We've built a Docker-based deployment tool to launch apps and sites fully c

* PHP 8.0 + 8.1
* MySQL 5.7+
* Laravel 8.0
* Laravel 8.0 or 9.0

## Features

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -17,11 +17,11 @@
],
"require": {
"php": "^8.0|^8.1",
"illuminate/support": "^8.79"
"illuminate/support": "^8.79|^9.0"
},
"require-dev": {
"mockery/mockery": "^1.3.3",
"orchestra/testbench": "^6.23",
"orchestra/testbench": "^6.23|^7.0",
"phpunit/phpunit": "^9.4"
},
"autoload": {
Expand Down
4 changes: 3 additions & 1 deletion src/Searcher.php
Expand Up @@ -370,10 +370,12 @@ public function simplePaginate($perPage = 15, $pageName = 'page', $page = null):
*/
public function parseTerms(string $terms, callable $callback = null): Collection
{
$callback = $callback ?: fn () => null;

return Collection::make(str_getcsv($terms, ' ', '"'))
->filter()
->values()
->when($callback, function ($terms, $callback) {
->when($callback !== null, function ($terms) use ($callback) {
return $terms->each(fn ($value, $key) => $callback($value, $key));
});
}
Expand Down

0 comments on commit a3bed78

Please sign in to comment.