定制 outerweb/nova-link-picker 二次开发

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

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

outerweb/nova-link-picker

最新稳定版本:v1.1.0

Composer 安装命令:

composer require outerweb/nova-link-picker

包简介

A Laravel Nova field to generates links

README 文档

README

Caution

This package has been abandoned.

Nova Link Picker

Latest Version on Packagist Total Downloads

This package provides a Nova field to generate a link. It shows a select field with the routes of your application you want to be used as a link. It also provides fixed options like external, mailto and tel. Route model binding is automatically applied to the parameters to give the user dropdowns with the available options.

Screenshots

Edit

Index

Index

Index

Detail

Detail

Installation

You can install the package via composer:

composer require outerweb/nova-link-picker

You can publish the config file with:

php artisan vendor:publish --tag="nova-link-picker-config"

This is the contents of the published config file:

return [
    'link_entity' => \Outerweb\NovaLinkPicker\Entities\Link::class,
    'api_base_url' => '/nova-vendor/outerweb/nova-link-picker',
    'available_options' => [
        'open_in_new_tab' => true,
        'download' => true,
    ]
];

Usage

This field stores its value as a JSON string in the database. So you need to make sure the column in the database is a json column (or text if json is not (yet) supported by your DB engine).

The value of the field looks like this:

{
    "routeName": string,
    "parameters": [
        [
            "name": string,
            "value": int|string
        ]
    ],
    "options": {
        "openInNewTab": bool,
        "download": bool
    }
}

To make it easier to work with this value, you can use the Outerweb\NovaLinkPicker\Casts'LinkPickerCast cast.

use Outerweb\NovaLinkPicker\Casts\LinkPickerCast;

...

protected $casts = [
    'link' => LinkPickerCast::class,
];

This cast will cast the value to a Outerweb\NovaLinkPicker\Entities'Link instance.

On this instance you can call the following methods / properties:

// Returns the route name as a string
// The routeName value can come from your applications registered routes
// or from the fixed options when it starts with `external.`:
// - `external.url` for an external url
// - `external.mailto` for a mailto link
// - `external.tel` for a tel link
$link->routeName;

// Returns the parameters as an array
$link->parameters;

// Returns the options as an array
$link->options;

// Generate the route (just like you would do with Laravel's `route()` helper)
$link->route();

// Get the target attribute value for the link
$link->target();

// Check if the link is an external link
$link->isExternal();

// Check if the link should be a download link
$link->isDownload();

// Render the link attributes (`href`, `target` and optionally `download`)
// Example: <a {{ $link->renderAttributes() }}>Click me!</a>
$link->renderAttributes();

Add the following syntax to the routes you want to be available in the select field:

Route::get('my-route', function () {
    // ...
})->name('my-route')
    ->where('nova-link-picker', 'true');

By default, the label of the route will be the route name. If the route contains a dot, the label will split the parts with a ">" character. For example: my-route will be My route and my-route.sub-route will be My route > Sub route. You can always customize the label of your named routes by adding the following to your routes:

Route::get('my-route', function () {
    // ...
})->name('my-route')
    ->where('nova-link-picker', 'true')
    ->where('nova-link-picker-label', __('My custom label'));

Add the field to your Nova resource:

use Outerweb\NovaLinkPicker\Nova\Fields\LinkPicker;

...

public function fields(Request $request)
{
    return [
        LinkPicker::make('Link')
            // This will Str::limit() the value on the Nova index table
            ->abbreviated()
            // This will hide the `download` option
            ->withoutDownload()
            // This will hide the `open in new tab` option
            ->withoutOpenInNewTab(),
    ];
}

Overwriting

Sometimes your application requires some custom logic. We've tried to make it as easy as possible to overwrite the default behavior.

You can overwrite the LinkPicker field by creating a new field that extends the LinkPicker field. This way, you can just overwrite the methods you want to change.

namespace App\Nova\Fields;

use Outerweb\NovaLinkPicker\Nova\Fields\LinkPicker as BaseLinkPicker;

class LinkPicker extends BaseLinkPicker
{
    // Your custom code here
}

You can overwrite the Link entity by creating a new entity that extends the Link entity. This way, you can just overwrite the methods you want to change.

namespace App\Entities;

use Outerweb\NovaLinkPicker\Entities\Link as BaseLink;

class Link extends BaseLink
{
    // Your custom code here
}

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

outerweb/nova-link-picker 适用场景与选型建议

outerweb/nova-link-picker 是一款 基于 Vue 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 12 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 outerweb/nova-link-picker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 outerweb/nova-link-picker 我们能提供哪些服务?
定制开发 / 二次开发

基于 outerweb/nova-link-picker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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