How can we use "Spatie\translatable" package with "Spatie\Permission" to make role/permission name translatable. #1683
Unanswered
sachinkumar121
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I integrated Spatie\Translatable for multilanguage content and Spatie\Permission for role/permission-based user authorization.
I want to show the list of the user with their role and permission(according to locale) that assigned to them. By default, the Spatie\Permission package creates id, name, guard name fields for permission, and role table. So I create a new field custom_name for translatable. As I can't use the name field as translatable because the role(or permission) name string(for eg., manager) is used either in middleware or @can operator.
the problem is with the role object. When we fetch a role using the Role model i.e Role::find(1) then it will return the "App\Role Object" type object and when I fetch the role from the user like $user->roles()->first() then it will return the "Spatie\Permission\Models\Role Object" type object.
So translatable concept is not working with the "Spatie\Permission\Models\Role Object" or "Spatie\Permission\Models\Permission Object".
Beta Was this translation helpful? Give feedback.
All reactions