Comments (12)
Hello, I think you should propose this feature request to spatie/laravel-permission, if they will add this, we will definitely include it in this library.
from nova-permission.
Without extending the package, you could add a layer that uses the __()
translation helper.
from nova-permission.
@drbyte in some projects I also create a display_name column in permissions and roles tables for such purposes. If Spatie will add it, it would be awesome
from nova-permission.
It's being considered for v3, but nothing confirmed yet.
from nova-permission.
May be create own table for this and add hasOne relation? Or make your own migration for spatie permissions table, with adding title column. I think we can long wait for Spatie, if they coding v3.
This title needed only in Nova, not in other project code, so it not require "native support" from Spatie.
from nova-permission.
I have a solution for now.
In \Vyuldashev\NovaPermission\Permission
we add displayUsing
call with callback which will return translation:
Text::make(__('nova-permission-tool::permissions.name'), 'name')
// ...
->displayUsing(function ($value) {
return __('nova-permission-tool::permissions.names.' . $value);
}),
In project's resources/lang/vendor/nova-permission-tool/en/permissions.php
we add for example:
<?php
return [
'name' => 'Name',
'guard_name' => 'Guard Name',
'created_at' => 'Created at',
'updated_at' => 'Updated at',
'names' => [
'users-create' => 'Create Users',
],
];
Which will lead to this:
The same implementation can be applied for roles. If Spatie adds translatable option for permission and role names we will switch to it.
Waiting for feedback from @drbyte and @VTumanov.
from nova-permission.
I think it well be more useful if use two different columns. One for Users, second for Developers, they can check permissions keys with this page.
from nova-permission.
We can make a computed field then.
from nova-permission.
Then it looks great! Thanks Bro!
from nova-permission.
Just tagged v1.2.0. Check it out. You need to create in resources/lang/vendor/nova-permission-tool/en/permissions.php
display_names
array where key stands for permission name and value for display value. It wont show Display Name
column until there is at least one value.
from nova-permission.
Today i use this future, all good and work!
For other coders: in lang file you need use display_names
instead names
like in upper example
from nova-permission.
I think it well be more useful if use two different columns. One for Users, second for Developers, they can check permissions keys with this page.
The existing name
field should be the one used "by developers", since it's the one closed to "your app code". If you need to display it differently for "users"/whatever, you can either use the translation functions or add a separate field to the db and manage that field in your own app.
from nova-permission.
Related Issues (20)
- Error on update role and update user role HOT 3
- Roleselect required HOT 3
- Upgrade to spatie/laravel-permission v5 HOT 17
- Policy vs Direct (Bug?) HOT 9
- Not bug, Request info/help HOT 1
- support for spatie permissions v5? HOT 7
- Laravel 9 support HOT 7
- Laravel Nova 4 support HOT 7
- Hardcoded user name field trying to attach user to a role from Nova resource HOT 1
- Add Azerbaijan language
- Hide Certain Guards?
- There was a problem submitting the form
- Add wildcard permissions support
- 403 error HOT 1
- Remove a role from the list HOT 1
- Role detail page limit HOT 1
- Duplicates in sidebar HOT 1
- Select all checkbox
- Permissions table got deleted accidentally HOT 1
- Seeder JSON Generator
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nova-permission.