I am using cviebrock slug libray and stuck on this error "Undefined index: separator"

Viewed 2675

Undefined index: separator

My Post Model

use Illuminate\Database\Eloquent\Model;
use Cviebrock\EloquentSluggable\Sluggable;
use Cviebrock\EloquentSluggable\SluggableScopeHelpers;
class Post extends Model
{
    use SluggableScopeHelpers;
    use Sluggable;
    public function sluggable()
    {
        return [
            'slug' => [
                'source' => 'title',
                'onUpdate' => true
            ]
        ];
    }

I added this class into config/app.php, added slug column in the posts table

Cviebrock\EloquentSluggable\ServiceProvider::class,
1 Answers

this error has occured because the package didn't config correctly! you can publish the vendor directory into your 'config' directory by:

php artisan vendor:publish --provider="Cviebrock\EloquentSluggable\ServiceProvider"

This will add a 'sluggable.php' file in 'config' directory. In this file you can find 'separator' index and other items such as onUpdate, source and etc. probably this way will help you. if not, run:

php artisan config:clear

This command will remove the configuration cache file. then publish vendor directory again!

I hope this way can help you. You can also see https://github.com/cviebrock/eloquent-sluggable/issues/435

Related