Danu Akbar Danu Akbar - 3 months ago 16
PHP Question

Laravel : 'Trait 'App\Sluggable' not found' even The Provider Was Added

I got an error when i try to add slug to my laravel project.

This my provider

Cviebrock\EloquentSluggable\ServiceProvider::class,


And here's my composer.json

"require": {
....
"cviebrock/eloquent-sluggable": "^4.0"
},


And here's my model

<?php

...
use Cviebrock\EloquentSluggable\SluggableTrait;

class Artikel extends Model
{
....
use Sluggable;
...
public function sluggable()
{
return [
'slug' => [
'source' => 'artikel_judul'
]
];
}
}


And here is my errormy error

Answer

As per the docs, it should be like so

use Cviebrock\EloquentSluggable\Sluggable;

class Artikel extends Model
{
  ....
  use Sluggable;
  ...
Comments