Spatie/Laravel-Permissions: Undefined method translationEnabled() error

3.6k Views Asked by At

I am working on Laravel project that is using the following libraries:

  • Spatie/Laravel-Permissions
  • Laravel-Backpack Base, Crud
  • Laravel-Backpack/PermissionManager

Every time, I try to create new role or permission from the admin interface, I get the this error:

Call to undefined method Spatie\Permission\Models\Role::translationEnabled()

I have already done the necessary setup, but cant seem make this work.

Thanks in advance!

Edit:

The error is triggered by a call on line 1 of this view:

https://github.com/Laravel-Backpack/CRUD/blob/master/src/resources/views/form_content.blade.php

3

There are 3 best solutions below

1
On BEST ANSWER

I was able to solve the issue. I had already installed Spatie/Laravel-Permissions before installing Laravel-Backpack/PermissionManager which require the same library. However, I had made some changes to the config that had overwritten the configuration for PermissionManager which caused the error. Removing those configurations solved the issue.

0
On

Try to replace default Roles and Permission models on backup's

in the file config/permission.php replace:

'permission' => Spatie\Permission\Models\Permission::class,    
to
'permission' => \Backpack\PermissionManager\app\Models\Permission::class,
    

And

'role' => Spatie\Permission\Models\Role::class,
to
'role' => \Backpack\PermissionManager\app\Models\Role::class,
0
On

Its VS Code related problem. I resolved it using below solution.

Ctrl + Shift + P // To open the editor commands

// then type in or scroll down and select...

Developer:Reload Window