-
-
Notifications
You must be signed in to change notification settings - Fork 461
method
Shipu Ahamed edited this page Sep 3, 2016
·
1 revision
Defines the method used to turn the sluggable string into a slug. There are three possible options for this configuration:
-
When
method
is null (the default setting), the package uses Cocur/Slugify to create the slug. -
When
method
is a callable, then that function or class method is used. The function/method should expect two parameters: the string to process, and a separator string. For example, to duplicate the default behaviour, you could do:
'method' => ['Illuminate\\Support\\Str', 'slug'],
- You can also define
method
as a closure (again, expecting two parameters):
'method' => function ($string, $separator) {
return strtolower(preg_replace('/[^a-z]+/i', $separator, $string));
},
Any other values for method
will throw an exception.
For more complex slugging requirements, see Extending Sluggable below.