Skip to content

Commit

Permalink
edit changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Feb 15, 2018
1 parent 20174d0 commit 99b2215
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-sluggable` will be documented in this file

## 2.1.3 - 2018-02-15

- fix for models with non incrementing primary keys

## 2.1.2 - 2018-02-08

- Support Laravel 5.6
Expand Down
8 changes: 7 additions & 1 deletion src/HasSlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,14 @@ protected function makeSlugUnique(string $slug): string
*/
protected function otherRecordExistsWithSlug(string $slug): bool
{
$key = $this->getKey();

if ($this->incrementing) {
$key = $key ?? '0';
}

return (bool) static::where($this->slugOptions->slugField, $slug)
->where($this->getKeyName(), '!=', $this->getKey() ?? '0')
->where($this->getKeyName(), '!=', $key)
->withoutGlobalScopes()
->first();
}
Expand Down

0 comments on commit 99b2215

Please sign in to comment.