tanvirofficials/copy-clone

Laravel Nova 扩展包,用于复制或克隆资源数据。

2.4.0 2021-10-02 19:01 UTC

This package is auto-updated.

Last update: 2024-09-24 17:17:18 UTC


README

由 →tanvirofficials

将 Copy-clone 扩展包安装到您的 nova 项目中

$ composer require tanvirofficials/copy-clone

用法

use Tanvirofficials\CopyClone\CopyClone;
CopyClone::make()
    ->withMeta([
        'resource' => 'posts', // resource url
        'model' => 'App\Post', // model path
        'id' => $this->id, // id of record
        'relations' => ['tags', 'comments'], // an array of any relations to load (nullable).
        'except' => ['status'], // an array of fields to not replicate (nullable).
        'override' => ['status' => 'published'] // an array of fields and values which will be set on the modal after Cloning(nullable).
    ]),

您可以将它放置在右下角或右上角。

对于右下角,将以下代码放置在所有 nova 字段下方。

Demo Image 1.1

对于右上角,将代码放置在所有 nova 字段上方。

Demo Image 1.2

您可以自定义复制克隆按钮的文本→

CopyClone::make()
    ->withMeta([
           .... include other metas .... ,

          'button_text' => 'Custom Copy\Clone Button', // By deafult its copy\clone  icon.


    ]),
Demo image 1.3

您可以自定义自己的对话框。默认情况下 →

自定义确认对话框。

→使用 title,body,confirm_button_text 和 cancle_button_text 元数据来自定义

Demo image 2
CopyClone::make()
    ->withMeta([
           .... include other metas .... ,

           'title' => 'Custom Title',  // by default 'title' => 'Confirmation'
           'body' => 'Custom Body',   // by default 'body' => 'Are you sure ?'
           'confirm_button_text' => 'Custom Confirm Button' ,   // by default 'confirm_button_text' => 'Copy\Clone'
           'cancle_button_text' => 'Custom Cancle Button'   // by default 'cancle_button_text'  => 'Cancle'
    ]),
Demo image 3

→此包仅在资源详情页中可用。