Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Call to undefined method getTranslatedLocales() #238

Answered by mxm1070
hopkins385 asked this question in Q&A
Discussion options

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();
 });
You must be logged in to vote

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

Comment options

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;
You must be logged in to vote
1 reply
Comment options

Yes! I didn't realize the import was incorrect. Thanks for the hint! :-)

Answer selected by hopkins385
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /