Twill advanced permissions

I've followed the documentation with regard to adding the enabled and permission key to config/twill.php. I ran the migrations, although it reported back there were no migrations. However i don't see the permissions tab in my module. What am i missing?
33 Replies
ifox
ifox2y ago
Hi @.zeenux did you add a module to the configuration? Do you see Roles management in the CMS users section?
.zeenux
.zeenuxOP2y ago
No i can't see it. i did add a module to the config
ifox
ifox2y ago
ok so the feature isn't enabled
.zeenux
.zeenuxOP2y ago
'modules' => ['posts'],
ifox
ifox2y ago
can you share your config?
.zeenux
.zeenuxOP2y ago
'enabled' => [ 'permissions-management' ], 'permissions' => [ 'level' => \A17\Twill\Enums\PermissionLevel::LEVEL_ROLE, 'modules' => ['posts'], ],
ifox
ifox2y ago
oh you need a boolean value in enabled
.zeenux
.zeenuxOP2y ago
like 'enabled'=[ ?=true]
ifox
ifox2y ago
'permissions-management' => true
.zeenux
.zeenuxOP2y ago
Call to a member function permissions() on string Error now. Call to a member function permissions() on string (View: /var/www/html/twill_perms/vendor/area17/twill/views/layouts/main.blade.php
ifox
ifox2y ago
does your posts module have a morphmap?
.zeenux
.zeenuxOP2y ago
no
ifox
ifox2y ago
so you cant reference it with just 'posts' you can use the fully qualified model instead, but I'd recommend you to use morphmaps on all your models
.zeenux
.zeenuxOP2y ago
can't find the documentation on morphmap
ifox
ifox2y ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
.zeenux
.zeenuxOP2y ago
I know laravel morphtomany. However i don't have a permission model to reference to
ifox
ifox2y ago
it isn't about twill permission model, it is about your own post model if you haven't defined a morphmap mapping 'posts' to your Post model Laravel and subsequently Twill won't find it
.zeenux
.zeenuxOP2y ago
so defined in AppServiceProvider boot method Relation::enforceMorphMap([ 'post' => 'App\Models\Post',
]); Still doesn't work
ifox
ifox2y ago
https://discord.com/channels/811936425858695198/1105835250636030082/1105835732964212817 you used posts here, so you should use posts in the morphmap too
.zeenux
.zeenuxOP2y ago
'modules' => ['post'], not working still.
ifox
ifox2y ago
use posts, since that's the name of your module (plural model name). and did you migrate after fixing your enabled config?
.zeenux
.zeenuxOP2y ago
i ran the migration, but can't see roles management in the dashboard
ifox
ifox2y ago
here's the code that adds a "Roles" section to the users navigation:
NavigationLink::make()->title(twillTrans('twill::lang.permissions.roles.title'))
->forModule('roles')
->onlyWhen(
fn() => config('twill.enabled.permissions-management') && Auth::user()->can('edit-user-roles')
)
NavigationLink::make()->title(twillTrans('twill::lang.permissions.roles.title'))
->forModule('roles')
->onlyWhen(
fn() => config('twill.enabled.permissions-management') && Auth::user()->can('edit-user-roles')
)
so if config('twill.enabled.permissions-management') is true and I assume that you're logged in as a superadmin, you should definitely see it
.zeenux
.zeenuxOP2y ago
sorry to be a bother but still nothing.
No description
ifox
ifox2y ago
i'm talking about the CMS users section, not a record of your own module and you won't see any change at the record level if you don't use the highest level of permissions available
.zeenux
.zeenuxOP2y ago
RoleGroupItem
ifox
ifox2y ago
right now you are using the ROLE level, which is:
When using the permission level role users will be given a role. Roles can be managed from the admin interface subnavigation when managing users.
.zeenux
.zeenuxOP2y ago
LEVEL_ROLE_GROUP_ITEM
ifox
ifox2y ago
yes
.zeenux
.zeenuxOP2y ago
That did it. Thanks a million for the patient support. Can i disable the email notification that goes after registering a user? No morph map defined for model [A17\Twill\Models\Role]. Added a morphmap for role and it works
ifox
ifox2y ago
if you don't enable the user and register it yourself from the cms before enabling, I don't think they are notified that's because you used enforceMorphMap you can use ::morphMap if you don't want to have to register Twill internal models but that's something we should address
Want results from more Discord servers?
Add your server