Yii2 slug behavior
The preferred way to install this extension is through Composer.
Either run php composer.phar require seacjs/yii2-slug-behavior "*"
or add "seacjs/yii2-slug-behavior": "*"
to the require section of your composer.json
Attach the behavior in your model:
public function behaviors()
{
return [
'slug' => [
'class' => 'seacjs\behaviors\Slug',
'slugAttribute' => 'slug',
'attribute' => 'name',
'translit' => true,
]
];
}
or use another class Sluggable, work with transliteration
Sluggable extends SluggableBehavior
public function behaviors()
{
return [
'slug' => [
'class' => 'seacjs\behaviors\Sluggable',
'slugAttribute' => 'slug',
'attribute' => 'name',
]
];
}