CARTALYST/TAGS set slug generator for others language

CARTALYST/TAGS is powerful taggable package for laravel, it’s so nice and easy to use, but having some problem with languages except english.

The problem is, by default, slug was be set Illuminate\Support\Str::slug and we don’t pass any properties ref, by the way, Illuminate\Support\Str::slug supported multiple languages ref, but need to pass option properties, if not, . For now, the package provide setSlugGenerator method, you can do belong and set customize slug parser.

public function slugify()
{
$this->setSlugGenerator(function($name) {
return base64_encode($name); // set what you want.
});

return $this;
}

For better, you can extract it and compose Cartalyst\Tags\TaggableTrait, like this:

namespace App\Foundation;
use Cartalyst\Tags\TaggableTrait;
trait Slugify
{
use TaggableTrait;
public function slugify()
{
$this->setSlugGenerator(function($name) {
return base64_encode($name);
});
return $this;
}
}