Flash
Flash
TCTwill CMS
Created by Flash on 1/27/2025 in #👊support
Twill 3 custom roles & permissions are not working
Hello, I'm trying to create new roles and add permissions to them. i want to make some modules only accessible by some of the new roles I've created. I followed the twill documentation and I still get Forbidden yellow screen error when i try to access a certain module as the new user role i created. here is my code, Models/Enums/UserRole.php
class UserRole extends Enum
{
const VIEWONLY = 'View Only';
const PUBLISHER = 'Publisher';
const ADMIN = 'Admin';

const VIEWER = 'Viewer';
const EDITOR = 'Editor';
}
class UserRole extends Enum
{
const VIEWONLY = 'View Only';
const PUBLISHER = 'Publisher';
const ADMIN = 'Admin';

const VIEWER = 'Viewer';
const EDITOR = 'Editor';
}
Providers/AppServiceProvider.php
public function register(): void
{ \A17\Twill\Facades\TwillPermissions::setRoleEnum(\App\Models\Enums\UserRole::class);
}
public function register(): void
{ \A17\Twill\Facades\TwillPermissions::setRoleEnum(\App\Models\Enums\UserRole::class);
}
Providers/AuthServiceProvider.php
public function boot(): void
{
Gate::define('list', function ($user) {
return in_array($user->role_value, [
UserRole::VIEWONLY,
UserRole::VIEWER,
UserRole::EDITOR,
UserRole::ADMIN
]);
});
}
public function boot(): void
{
Gate::define('list', function ($user) {
return in_array($user->role_value, [
UserRole::VIEWONLY,
UserRole::VIEWER,
UserRole::EDITOR,
UserRole::ADMIN
]);
});
}
It looks like the code in AuthServiceProvider is not redefining twill's default permissions. how do i fix this?
1 replies
TCTwill CMS
Created by Flash on 11/27/2024 in #👊support
Creating a menu with more than 2 levels
How do i create a menu with more than 2 levels? Like I want to have nested items within the nested items. Is that possible?
2 replies
TCTwill CMS
Created by Flash on 11/10/2024 in #👊support
Multi Language Same Slugs
Can someone give me an idea on how to achieve this. I'm building a multi language site and I want to have the same slugs for all languages. Default language should not have any base like below. Ex: www.sample.com/post-url www.sample.com/fr/post-url www.sample.con/es/post-url Is there any method i can call to get the data of a certain locale like, $page->forSlugWithLocale(slug, locale) Please help
2 replies