Laravel-permission: Do you support permissions and roles to add alias features?

Created on 25 Oct 2017  路  6Comments  路  Source: spatie/laravel-permission

I think this is useful features.

Most helpful comment

I'm not sure this solves your problem, but to display permission and role names in a more user friendly way in the interface, perhaps you could pass names through the Laravel translation functions, like

__($role->name)

and define the display string you want in the language files?

https://laravel.com/docs/5.5/localization#using-translation-strings-as-keys

All 6 comments

Can you explain in more detail?

Because of my background to the management of these rights and role, but I was using Chinese, I can not directly show these permissions and role values, the user will feel strange, so I had to create a new table to do these permissions and roles of the Chinese show that if you can support the alias native so tell me about the demand will be easier to use.

I have faced similar issue in past.
Right now both role and permission tables have a single database column name that is being used as unique slug.
For example the permission name is create_post and i want to show Ability to create posts on UI.
Same goes with role.
I would like to have a new column to hold display_name that we can allow our customer to change without the need of changing the slug (name).

I can see how this is a problem. However you can easily update the permissions table migration to include a display_name column. The Permission class is an eloquent model so you can set that display name property like this:

Permission::create(['name' => 'articles.edit', 'display_name' => "Edit articles"]);

I'm not sure if we want to include this in the actual package as it's something you can easily do yourself. Maybe we can include a section in the readme about custom properties? (mentioning #479 so I don't forget)

I'm not sure this solves your problem, but to display permission and role names in a more user friendly way in the interface, perhaps you could pass names through the Laravel translation functions, like

__($role->name)

and define the display string you want in the language files?

https://laravel.com/docs/5.5/localization#using-translation-strings-as-keys

@bjuppa This makes more sense to me

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dylangeorgeharbour picture dylangeorgeharbour  路  3Comments

Dreambox13 picture Dreambox13  路  3Comments

ghost picture ghost  路  3Comments

tripex picture tripex  路  3Comments

MichalKrakow picture MichalKrakow  路  4Comments