wehaa/custom-links 问题修复 & 功能扩展

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

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

wehaa/custom-links

最新稳定版本:v0.1.1

Composer 安装命令:

composer require wehaa/custom-links

包简介

Adds custom links to Nova sidebar.

README 文档

README

This tool allows you to add a custom links as a section in your sidebar or a single top level link.

Installation

You can install the package in to a Laravel app that uses Nova via composer:

composer require wehaa/custom-links

Then you must register the tool with Nova. This is typically done in the tools method of the NovaServiceProvider.

// in app/Providers/NovaServiceProvider.php

use Wehaa\CustomLinks\CustomLinks;

// ...

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

To publish the config file to config/custom-links.php run:

php artisan vendor:publish --provider="Wehaa\CustomLinks\ToolServiceProvider"

To add links to the navigation section you need to add entries to the links section in the config file.

return [
    'links' => [
        '{TEXT}' => [                           // Top level section title text
            '_can'    => '{PERMISSION}'         // The name of the permission
            '_icon'   => '{ICON}',              // SVG icon code (optional)
            '_url'    => '{URL}',               // URL (optional if _links is present)
            '_target' => '{TARGET}',            // Link target (optional) 
            '_links'  => [                      // Section extra links (optional if _url is present
                '{TEXT}' => [                   // Sub section text
                    '_can'    => '{PERMISSION}' // The name of the permission
                    '_url'    => '{URL}',       // URL
                    '_target' => '{TARGET}',    // Link target (optional)
                ]
            ]
        ]
    ]
];

The included config file will add some links you can use as an example.

Authorization

If you would like to only expose your links to certain users, you may chain the canSee method onto your tool's registration.

// in app/Providers/NovaServiceProvider.php

use Wehaa\CustomLinks\CustomLinks;

// ...

public function tools()
{
    return [
        // ...
        (new CustomLinks)->canSee(function ($request) {
            return false;
        }),
    ];
}

In addition, you can add the key _can in the links array, including the child links as well. We will use the can() function to check if the user has the permission to see the links or not.

Please note that if you don't want any authorization checks, do not add the _can key.

return [
    'links' => [
        '{TEXT}' => [                           // Top level section title text
            '_can'    => '{PERMISSION}'         // Checks if the link and sublinks can be shown
            // ...
            '_links'  => [                      // Section extra links (optional if _url is present
                '{TEXT}' => [                   // Sub section text
                    '_can'    => '{PERMISSION}' // Checks if the link can be shown
                    // ...
                ]
            ]
        ]
    ]
];

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 5
  • Forks: 5
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-09