-
composer.json
Open in GitHub{ // "require": { "php": "^7.1|^8.0", // "myclabs/php-enum": "^1.5" }, // }
-
src/Models/Enums/UserRole.php
Open in GitHubuse MyCLabs\Enum\Enum; class UserRole extends Enum { const VIEWONLY = 'View only'; const PUBLISHER = 'Publisher'; const ADMIN = 'Admin'; }
-
src/Models/User.php
Open in GitHubuse A17\Twill\Models\Enums\UserRole; use Illuminate\Foundation\Auth\User as AuthenticatableContract; class User extends AuthenticatableContract { // public function getRoleValueAttribute() { if (!empty($this->role)) { if ($this->role == 'SUPERADMIN') { return "SUPERADMIN"; } return UserRole::{$this->role}()->getValue(); } return null; } // }
-
src/Http/Controllers/Admin/UserController.php
Open in GitHubuse A17\Twill\Models\Enums\UserRole; class UserController extends ModuleController { // protected function indexData($request) { return [ 'defaultFilterSlug' => 'published', 'create' => $this->getIndexOption('create') && $this->authFactory->guard('twill_users')->user()->can('manage-users'), 'roleList' => Collection::make(UserRole::toArray()), 'single_primary_nav' => [ 'users' => [ 'title' => twillTrans('twill::lang.user-management.users'), 'module' => true, ], ], 'customPublishedLabel' => twillTrans('twill::lang.user-management.enabled'), 'customDraftLabel' => twillTrans('twill::lang.user-management.disabled'), ]; } // }