PHP code example of lizhineng / nova-permission-tool

1. Go to this page and download the library: Download lizhineng/nova-permission-tool library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lizhineng / nova-permission-tool example snippets


// in app/Providers/NovaServiceProvider.php

// ...

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

// in app/Nova/User.php

// ...

public function fields()
{
    return [
        // ...

        MorphToMany::make('Roles', 'roles', \Lizhineng\PermissionTool\Role::class),

        MorphToMany::make('Permissions', 'permissions', \Lizhineng\PermissionTool\Permission::class),
    ];
}

php artisan vendor:publish --provider="Lizhineng\PermissionTool\ToolServiceProvider"