cviebrock/eloquent-sluggable
Generate SEO-friendly, unique slugs for Laravel Eloquent models automatically. Configure sources, separators, max length, reserved words, and update behavior; supports soft deletes and route model binding. Includes a SlugService and extensible hooks.
registerModelEvent() hook (#556, #561, thanks @standaniels)SluggableObserver::SAVED not always saving
the model (#558, #560, thanks @llewellyn-kevin)firstUniqueSuffix config settingsaved event, rather than
saving
source configuration (see #539 and #448)customizeSlugEngine and scopeWithUniqueSlugConstraints methods
to the trait, to enforce type hinting and return values
slugEngineOptions configuration option (see #454, thanks @Adioz01)^4.0null if model is updated with no source column loaded (#450, thanks @mylgeorge)SlugService::createSlug with an invalid attribute (#402, thanks @lptn)maxLengthKeepWords configuration option (#398)cocur/slugify to ^3.0getExistingSlugs when using global scopes (#327)Cocur\Slugify to ^2.3.onUpdate with unique (#317)SluggableScopeHelpers to work when using the short configuration syntax (#314).$config argument to SlugService::createSlug method for optionally overriding
the configuration for a statically generated slug (#286).SluggableScopeHelpers trait which restores some of the scoping and query
functionality of the 3.x version of the package (#280, thanks @unstoppablecarl and @Keoghan).onUpdate configuration option back to the package.SluggableScopeHelpers trait, and
how to use route model binding with slugs.sluggable() method.
on the model instead of a property, and configuration options are now camelCasefindBy...() scope/methods (can't really be used when a model
has multiple slugs ... plus the code is easy enough to implement in the model).onUpdate configuration option. If you want to re-generate a slug
on update, then set the model's slug to null before saving. Otherwise, existing
slugs will never be overwritten.createSlug() is no longer a static method on the model, but is a public method
on the SlugService class, with a different method signature (see docs).Cocur\Slugify to ^2.1 (#269 thanks @shadoWalker89).findBySlugOrId() (#205 thanks @Jaspur)null (#162 thanks @PallMallShow)build_from configuration (#171 thanks @blaxxi)getSlugEngine() method so that the Cocur\Slugify class can be configuredslugging and slugged Eloquent model eventsfindBySlugOrId() methods when the slug is numeric (#161 thanks @canvural)Model::createSlug('some string') (#185 thanks @phroggyy)use_cache option and supportinclude_trashed option not working for models that inherit the SoftDeletes trait (#136 thanks @ramirezd42)generateSuffix() method so you could use different strategies other than integers for making incremental slugs (#129 thanks @EspadaV8)max_length option only applies to string slugs (#64 thanks @enzomaserati)findBySlug() to return a model and getBySlug() to return a collection (#72 thanks @jaewun and @Jono20202)max_length option only applies to string slugs (#64 thanks @enzomaserati)getExistingSlugs() method to trait (#36 thanks @neilcrookes).on_update and unique are set (#14, #16, thanks @mikembm, @JoeChilds).isIncremented method static to solve possible "not in object context" error (#15, thanks @mayoz).method didn't take into account a custom separator.include_trashed wasn't working because you can't read the protected softDelete property of the model.include_trashed option to include soft-deleted models when checking for uniqueness (#8, thanks @slovenianGooner).reserved configuration option prevents generated slugs from being from a list of "reserved" names (e.g. colliding with routes, etc.) (#2, thanks @ceejayoz).How can I help you explore Laravel packages today?