Giter VIP home page Giter VIP logo

nova-permission-tool's Introduction

Nova Permission Tool.

This tool allows you to create and manage rules and permissions for nova resources. After installation, the default nova resource permissions will be generated for all available resources and resource actions.

Requirements & Dependencies

This tool uses Spatie Permission package.

Installation

You can install the package via composer:

composer require digitalcloud/nova-permission-tool

You can publish the migration with:

php artisan vendor:publish --provider="Spatie\Permission\PermissionServiceProvider" --tag="migrations"

After the migration has been published you can create the role- and permission-tables by running the migrations:

php artisan migrate

Usage

You must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider, in app/Providers/NovaServiceProvider.php.

use DigitalCloud\PermissionTool\PermissionTool;
// ....

public function tools()
{
    return [
        // ...
        new PermissionTool(),
        // ...
    ];
}

To allow the tool to generate permissions actions, you need to se the name of the action. Actions with no names will not be generated automatically.

<?php

namespace App\Nova\Actions;

use Laravel\Nova\Actions\Action;

class YourAction extends Action {
    
    // ...

    public $name = 'send email';
    
    // ...

}

and then in the resource you can authorize the action:

<?php

namespace App\Nova;

use App\Nova\Actions\YourAction;
use Illuminate\Support\Facades\Gate;
use Illuminate\Http\Request;


class Quotation extends Resource {
    
    // ...
    
    public function actions(Request $request) {
        return [
            (new YourAction())->canSee(function ($request) {
                return Gate::check('send email'); // the same name of the action
            })->canRun(function ($request) {
                return Gate::check('send email'); // the same name of the action
            })
        ];
    }
    
    // ...
}

Images

per

nova-permission-tool's People

Contributors

devmtm avatar boyfromhell avatar 42phoenix42 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.