Skip to content
Shipu Ahamed edited this page Sep 3, 2016 · 1 revision

method

Defines the method used to turn the sluggable string into a slug. There are three possible options for this configuration:

  1. When method is null (the default setting), the package uses Cocur/Slugify to create the slug.

  2. 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'],
  1. 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.

Clone this wiki locally