Skip to content

Commit

Permalink
Merge pull request #7 from markwalet/6-add-laravel-7-support
Browse files Browse the repository at this point in the history
Add laravel 7 support
  • Loading branch information
markwalet authored Mar 12, 2020
2 parents e631364 + 9148134 commit 62013e8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
3 changes: 0 additions & 3 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
preset: laravel
enabled:
- alpha_ordered_imports
disabled:
- length_ordered_imports
- simplified_null_return
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ env:
- ILLUMINATE_VERSION=5.5.* PHPUNIT_VERSION=~6.0 TESTBENCH_VERSION=3.5.*
- ILLUMINATE_VERSION=5.8.* PHPUNIT_VERSION=^7.5 TESTBENCH_VERSION=3.8.*
- ILLUMINATE_VERSION=6.* PHPUNIT_VERSION=^8.0 TESTBENCH_VERSION=4.*
- ILLUMINATE_VERSION=7.* PHPUNIT_VERSION=^8.5 TESTBENCH_VERSION=5.*

matrix:
exclude:
- php: 7.1
env: ILLUMINATE_VERSION=6.* PHPUNIT_VERSION=^8.0 TESTBENCH_VERSION=4.*
- php: 7.1
env: ILLUMINATE_VERSION=7.* PHPUNIT_VERSION=^8.5 TESTBENCH_VERSION=5.*

before_install: # Update requirements to fit environment variables.
- composer require "illuminate/support:${ILLUMINATE_VERSION}" --no-update --prefer-dist
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## [Unreleased](https://github.com/markwalet/laravel-hashed-route/compare/v2.1.0...master)

### Added
- Add support for Laravel 7. ([#6](https://github.com/markwalet/laravel-hashed-route/issues/6))

### Added
- Added Codecov integration.

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"require": {
"php": ">=7.0.12",
"hashids/hashids": "~2.0|~3.0",
"illuminate/config": "~5.5|6.*",
"illuminate/database": "~5.5|6.*",
"illuminate/support": "~5.5|6.*",
"illuminate/config": "~5.5|6.*|7.*",
"illuminate/database": "~5.5|6.*|7.*",
"illuminate/support": "~5.5|6.*|7.*",
"jenssegers/optimus": "^0.2.3"
},
"require-dev": {
"orchestra/testbench": "~3.5|4.*",
"orchestra/testbench": "~3.5|4.*|5.*",
"phpunit/phpunit": "~6.0||~7.0||~8.0"
},
"autoload": {
Expand Down
5 changes: 3 additions & 2 deletions src/Concerns/HasHashedRouteKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,19 @@ public function getRouteKey()
* Retrieve the model for a bound value.
*
* @param mixed $value
* @param string|null $field
* @return Model|null
* @throws MissingDriverException
*/
public function resolveRouteBinding($value)
public function resolveRouteBinding($value, $field = null)
{
try {
$value = $this->getCodec()->decode($value);
} catch (InvalidHashException $e) {
return null;
}

return self::query()->where($this->getRouteKeyName(), $value)->first();
return self::query()->where($field ?? $this->getRouteKeyName(), $value)->first();
}

/**
Expand Down

0 comments on commit 62013e8

Please sign in to comment.