定制 daliendev/permissiongroup 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

daliendev/permissiongroup

最新稳定版本:0.0.2

Composer 安装命令:

composer require daliendev/permissiongroup

包简介

Permission Group for Laravel Nova allows for the management of various permission values within a single JSON column.

README 文档

README

Prerequisites

  1. Laravel Nova 4 installed in your application
  2. Composer installed on your system

Installation

composer require daliendev/permissiongroup

Prepare your migrations

You will need a column in JSON format.

class CreateRolesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('roles', function (Blueprint $table) {
            ...
            $table->json('permissions')->nullable();
            ...
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('roles');
    }
}

Basic Usage

To use the PermissionGroup field in your Nova application, you need to add the field to your Nova resource. To do this, simply add the following code:

use Daliendev\PermissionGroup

public function fields(Request $request)
{
    return [
        ...
        PermissionGroup::make('Permissions', 'permissions')  
        ->on(User::class)  
        ->on(Role::class)  
        ...
    ];
}

This will display two CRUD oriented BooleanGroups and all the value will be stored in same {permissions} attribute/column of your model.

Custom permissions can also be specified (in addition to the CRUD on a resource and as an independent group):

    PermissionGroup::make('Permissions', 'permissions')  
        ->on(User::class, [  
            'test' => 'Test'  
        ])  
        ->on(Role::class)  
        ->with('Other', [
            'can_view_secret_page' => 'can view secret page'
        ])  
        ->with('Other2', [  
            'can_view_logs' => 'can view logs'  
        ]),

So permissions column of your role can store as much value as needed in JSON format:

["can_view_role", "can_view_user", "can_view_logs_other", "test_user"]

As all Laravel Nova Fields the following methods may be used to show / hide fields based on the display context:

    showOnIndex
    showOnDetail
    showOnCreating
    showOnUpdating
    showOnPreview
    showWhenPeeking
    hideFromIndex
    hideFromDetail
    hideWhenCreating
    hideWhenUpdating
    onlyOnIndex
    onlyOnDetail
    onlyOnForms
    exceptOnForms

For more details please refer to related Laravel Nova documentation page.

Some example screenshots:

Permission Group on Form page Permission Group on Detail page Permission Group on Index page

2023

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固