Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaur authored Oct 18, 2023
2 parents ce00626 + b7e6373 commit da968a9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
uses: aglipanci/laravel-pint-action@2.2.0

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
12 changes: 7 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, macos-latest]
php: [8.2, 8.1]
laravel: [10.*]
stability: [prefer-lowest, prefer-stable]
stability: [prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
testbench: ^8.0
carbon: ^2.63
collision: ^7.9

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -32,6 +33,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
tools: composer:v2
coverage: none

- name: Setup problem matchers
Expand All @@ -41,8 +43,8 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" nunomaduro/collision:${{ matrix.collision }} --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress --ansi
- name: List Installed Dependencies
run: composer show -D
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: Update CHANGELOG
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Changelog

All notable changes to `laravel-human-id` will be documented in this file.

## 1.1.0 - 2023-10-18

**Full Changelog**: https://github.com/leMaur/laravel-human-id/compare/1.0.0...1.1.0
17 changes: 6 additions & 11 deletions src/Concerns/HasHuids.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lemaur\HumanId\Concerns;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\Eloquent\Relations\Relation;
Expand All @@ -12,8 +13,6 @@ trait HasHuids
{
/**
* Initialize the trait.
*
* @return void
*/
public function initializeHasHuids(): void
{
Expand All @@ -22,8 +21,6 @@ public function initializeHasHuids(): void

/**
* Get the columns that should receive a unique identifier.
*
* @return array
*/
public function uniqueIds(): array
{
Expand All @@ -33,7 +30,6 @@ public function uniqueIds(): array
/**
* Generate a new ULID for the model.
*
* @return string
* @throws RuntimeException
*/
public function newUniqueId(): string
Expand Down Expand Up @@ -67,11 +63,10 @@ public function newUniqueId(): string
* @param Model|Relation $query
* @param mixed $value
* @param string|null $field
* @return Relation
*
* @throws ModelNotFoundException
*/
public function resolveRouteBindingQuery($query, $value, $field = null): Relation
public function resolveRouteBindingQuery($query, $value, $field = null): Relation|Builder
{
if ($field && ! Str::isHuid($value) && in_array($field, $this->uniqueIds(), true)) {
throw (new ModelNotFoundException)->setModel(get_class($this), $value);
Expand All @@ -81,13 +76,15 @@ public function resolveRouteBindingQuery($query, $value, $field = null): Relatio
throw (new ModelNotFoundException)->setModel(get_class($this), $value);
}

if ($field === null && Str::isHuid($value)) {
$field = (string) config('human-id.field', 'huid');
}

return parent::resolveRouteBindingQuery($query, $value, $field);
}

/**
* Get the auto-incrementing key type.
*
* @return string
*/
public function getKeyType(): string
{
Expand All @@ -100,8 +97,6 @@ public function getKeyType(): string

/**
* Get the value indicating whether the IDs are incrementing.
*
* @return bool
*/
public function getIncrementing(): bool
{
Expand Down

0 comments on commit da968a9

Please sign in to comment.