Releases: whitecube/laravel-sluggable
Bug fix
Bug fix
v1.6.6 Fixed translated slug query since SQL injection fix
Security fix
- Fixed SQL query. Thanks @voidgraphics!
Laravel 11
What's Changed
- Added support for Laravel 11 by @jan-tricks in #5
New Contributors
- @jan-tricks made their first contribution in #5
Full Changelog: v1.6.3...v1.6.4
Bug fix
- Fixed infinite redirections for different models with matching slugs in another locale. Thanks @JonathanRixhon !
Laravel 10
Merge pull request #3 from whitecube/laravel-10 Laravel 10
v1.6.1
Fixed dependencies
v1.6.0
Added Laravel 9 compatibility
Added getSlugExistsQuery method (to allow overriding) & fixed unique slug generation
Fixed a problem with the slug generation if the slug already existed.
Previously, if the following slugs (foo
, foo-1
) existed in the database, the generated slug would end up being foo-1-1
.
Now, it correctly generates foo-2
.
Added getSlugExistsQuery
method to allow overriding at the model level
Imagine your slug has a unique constraint based on the user_id
. This means both user A and user B can have a post with the slug foo
, but they can only have one post with that slug, each.
Previously, the package would hardcode the query that checks if the slug exists, and this use case couldn't be handled; the package had no way of knowing that it had to check the slugs for each user individually.
This can now be done by overriding the getSlugExistsQuery
method:
protected function getSlugExistsQuery($whereKey, $slug)
{
return static::where($whereKey, $slug)
->where('user_id', $this->user_id)
->withoutGlobalScopes();
}
Support for PHP 8
v1.5.0 Added support for PHP 8