-
-
Notifications
You must be signed in to change notification settings - Fork 188
Call to undefined method getTranslatedLocales() #238
-
Hi guys,
I am experiencing some unexpected behavior. After installing according to the description and trying to create a new model, I get the following error message.
Call to undefined method App\Models\UserPage::getTranslatedLocales()
I am not using e.g. spatie translatable or any other multi-lang feature.
I tried to add just this missing method as an emtpy method without return, but then I get a SQL error saying slug has no default value.
Can anyone help?
Environment
Win10 x64 with XAMPP
Laravel Version ....... 9.25.1
PHP Version .............. 8.1.6
Composer Version ........... 2.3.10
spatie/laravel-sluggable": "^3.4",
Model:
use HasSlug;
/**
* Get the options for generating the slug.
*/
public function getSlugOptions(): SlugOptions
{
return SlugOptions::create()
->generateSlugsFrom('name')
->saveSlugsTo('slug');
}
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName(): String
{
return 'slug';
}
Migration:
Schema::create('user_pages', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
});
Beta Was this translation helpful? Give feedback.
All reactions
I also just had this problem and if you're like me and you have spatie/laravel-tags
installed then it's because PhpStorm suggested
use Spatie\Tags\HasSlug;
over
use Spatie\Sluggable\HasSlug;
Replies: 1 comment 1 reply
-
I also just had this problem and if you're like me and you have spatie/laravel-tags
installed then it's because PhpStorm suggested
use Spatie\Tags\HasSlug;
over
use Spatie\Sluggable\HasSlug;
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes! I didn't realize the import was incorrect. Thanks for the hint! :-)
Beta Was this translation helpful? Give feedback.