Skip to main content

Social and user-generated content

On a social feed, "Hello World" is not a collision to be resolved. Thousands of posts will carry the same title, and appending -2, -3, -1847 to their URLs helps nobody.

#[Polyslug(source: 'title', unique: false)] // two posts titled "Hello World" coexist — no "-2"; the id disambiguates: /p/hello-world_a1B
class Post extends Model implements Sluggable
{
use HasPolyslug;
}

With unique: false the slug is written as generated, the row is excluded from the uniqueness index, and each post still resolves by its encoded id: /p/hello-world_a1B and /p/hello-world_c9D are two different posts.

Everything else is unchanged — including the guarantee that a record has exactly one current slug per locale, which a separate index enforces regardless of this setting.

Two things this mode turns off:

  • The disambiguating suffix, which is the point.
  • The reserved list, because there is no suffix to escape into. Keep reserved words on models that stay unique: true.

It also cannot be combined with idLess: true — without an id in the URL there is nothing left to tell two posts apart, and the combination is rejected at configuration time.

See also