d1360l/laravel-role-manager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

d1360l/laravel-role-manager

Composer 安装命令:

composer require d1360l/laravel-role-manager

包简介

A Laravel package to manage the relationships between users and Spatie roles, with a permission-driven UI, configurable default role, and webmaster provisioning. Built by El Flaco Programa (EFP).

README 文档

README

A Laravel package to manage the relationship between users and Spatie roles, with a permission-driven UI, a configurable default role for new users, and webmaster provisioning. Built by El Flaco Programa (EFP).

Features

  • User ↔ role management UI: list users, search by email (prefix match), filter by role, and update a user's roles.
  • Permission-driven authorization: every action is authorized through policies that check permissions (never roles directly).
  • Role hierarchy: `webmaster > chief > staff > [unknown roles] > registered

    (no role)`. Users only see and manage users ranked below them.

  • Webmaster peers: optionally allow webmasters to manage other webmasters.
  • Default role for new users: automatically assign a configurable role on registration (toggleable from the UI).
  • Bilingual UI: English and Spanish, switchable from the settings page.
  • Self-contained, responsive views styled with Tailwind CSS.

Requirements

Before installing the package, ensure your application meets the following prerequisites:

  • PHP ^8.3
  • Laravel ^13.0
  • spatie/laravel-permission ^8.3 (installed and migrated)
  • Laravel Breeze installed in the consuming application (provides the users table and authentication scaffolding).
  • Your User model must use Spatie's HasRoles trait.

Installation

For detailed prerequisites, manual asset publishing, configuration options, and frontend customizations, please refer to our comprehensive Installation Guide.

Configuration

The published config file (config/efp-role-manager.php) lets you set:

  • user_model — the application's user model (auto-resolved by default).
  • routing — the URL prefix, route-name prefix, and middleware stack.
  • layout — the Blade layout component used by the module views.
  • roles / permissions — the role and permission names (renamable).
  • webmaster.emails — the email(s) provisioned as webmaster on install.
  • webmaster.can_manage_peers — allow webmasters to manage other webmasters.
  • default_role — factory default for the new-user default role.
  • localization — available locales and the default/fallback locale.
  • pagination.per_page — users shown per page in the listing.

Settings precedence: runtime settings live in the database and take priority over the config file (DATABASE > CONFIG). The config values are the factory defaults; efp-role-manager:install seeds them into the database.

Usage

Once installed, visit the module (default: /efp-role-manager/users) as a user who holds one of the management permissions:

Role Can manage
webmaster chiefs, staff, users, settings
chief staff, users
staff users
registered — (default role, no management)

Rules enforced by the policies:

  • No self-editing: nobody can change their own roles.
  • Hierarchy: you can only manage users ranked below you.
  • Webmaster peers: only webmasters can manage same-level peers, and only when webmaster.can_manage_peers is enabled.

Commands

Command Description
efp-role-manager:install Create roles/permissions, assign webmaster(s), seed settings. Safe to re-run (idempotent); never overwrites existing settings.
efp-role-manager:sync Overwrite the settings from the config defaults (explicit re-seed). Only touches settings.

Default role for new users

When enabled, users are assigned the configured default role upon registration (via Laravel's Registered event). The webmaster role can never be used as the default role. The feature and the role name are managed from the settings page.

Localization

The UI ships in English (default) and Spanish, switchable from the settings page. A middleware applies the selected locale on the module's routes only, so the rest of your application's locale is unaffected.

Upgrading & Uninstalling

License

The MIT License (MIT). Built by El Flaco Programa (EFP).

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固