-
-
Notifications
You must be signed in to change notification settings - Fork 461
uniqueSuffix
Shipu Ahamed edited this page Sep 3, 2016
·
1 revision
If you want to use a different way of identifying uniqueness (other than auto-incrementing
integers), you can set the uniqueSuffix
configuration to a function or callable that
generates the "unique" values for you.
The function should take three parameters: the base slug (i.e. the non-unique slug), the
separator string, and an \Illuminate\Support\Collection
of all the other slug strings
that start with the same slug. You can then do whatever you want to create a new suffix
that hasn't been used by any of the slugs in the collection. For example, if you wanted
to use letters instead of numbers as a suffix, this is one way to achieve that:
'uniqueSuffix' => function ($slug, $separator, Collection $list) {
$size = count($list);
return chr($size + 96);
}