aprendible/permission-ui 问题修复 & 功能扩展

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

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

aprendible/permission-ui

Composer 安装命令:

composer require aprendible/permission-ui

包简介

Role & permission management UI for Spatie Laravel Permission with team support.

README 文档

README

Role and permission management UI for Spatie Laravel Permission with team support, built with Inertia and React.

Requirements

  • PHP 8.3+
  • Laravel 13+
  • spatie/laravel-permission configured with team support (teams set to true)
  • Inertia + React stack
  • A Team model with a slug column as the route key

Installation

composer require aprendible/permission-ui

Publish config

php artisan vendor:publish --tag=permission-ui-config

Publish frontend pages (required)

php artisan vendor:publish --tag=permission-ui-resources

Configuration

The publishable config/permission-ui.php lets you configure:

Model Bindings

'models' => [
    'team' => App\Models\Team::class,
    'user' => App\Models\User::class,
    'membership' => App\Models\Membership::class,
],

The {team} route parameter is resolved using slug lookup on the configured team model.

Routes

'routes' => [
    'prefix' => 'settings/teams/{team}',
    'middleware' => ['web', 'auth', 'verified', \App\Http\Middleware\EnsureTeamMembership::class],
],

All routes are registered under this prefix with the given middleware stack.

Gate Abilities

'gates' => [
    'manage_roles' => 'updateMember',
    'manage_permissions' => 'update',
],

The package uses these gate names when authorizing actions. Your application must define them, typically via policies or Gate::define.

Routes

Method URI Action Name
GET {prefix}/roles RoleController@index permission-ui.roles.index
POST {prefix}/roles RoleController@store permission-ui.roles.store
GET {prefix}/roles/{role}/edit RoleController@edit permission-ui.roles.edit
PATCH {prefix}/roles/{role} RoleController@update permission-ui.roles.update
DELETE {prefix}/roles/{role} RoleController@destroy permission-ui.roles.destroy
GET {prefix}/permissions PermissionController@index permission-ui.permissions.index
POST {prefix}/permissions PermissionController@store permission-ui.permissions.store
DELETE {prefix}/permissions/{permission} PermissionController@destroy permission-ui.permissions.destroy
PATCH {prefix}/roles/{role}/permissions SyncRolePermissionsController permission-ui.roles.permissions.sync

Usage Example

// In your AppServiceProvider or a policy
Gate::define('updateMember', function (User $user, Team $team) {
    return $team->members()
        ->where('user_id', $user->id)
        ->where('role', TeamRole::Owner->value)
        ->exists();
});
{{-- Navigation link to the roles page for the current team --}}
<a href="{{ route('permission-ui.roles.index', $currentTeam) }}">
    Roles
</a>

Gate Reference

Config key Default ability Checked in
manage_roles updateMember All role operations
manage_permissions update All permission operations

Commands

permission-ui:make:permission

Create permissions for a new resource and register them in config:

# CRUD permissions (default: create, edit, delete, show)
php artisan permission-ui:make:permission Post

# Custom actions
php artisan permission-ui:make:permission Article --actions=create,edit,delete,publish,archive

Creates permissions like post:create, post:edit, etc., in the database and adds the resource to config/permission-ui.php under the resources key.

permission-ui:sync

Sync all permissions from config and enums to the database (idempotent):

php artisan permission-ui:sync

Run this on every deploy. It reads the resources array from config and ensures all permissions exist via findOrCreate.

Config reference

'resources' => [
    'post' => ['create', 'edit', 'delete', 'publish'],
    'category' => ['create', 'edit', 'delete'],
],

Once created, permissions appear automatically in the UI and can be assigned to roles from the role editor.

Development

composer install
php artisan test

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固