pdmfc/nova-info-card

一个Laravel Nova信息卡。

v1.0.1 2020-04-27 13:09 UTC

This package is auto-updated.

Last update: 2024-09-07 18:33:26 UTC


README

hero image

Total Downloads Latest Stable Version License

此包提供了一个简单的方法,可以将通知卡添加到Laravel Nova资源中。

安装

composer require pdmfc/nova-info-card

使用

use Pdmfc\NovaCards\Info;

//...

public function cards()
{
    return [
        (new Info())
            ->info('Some info message')
    ];
}

主题

此包包含4种预定义样式 - infosuccesswarningdanger。要选择主题,只需将其用作方法名称即可。

如果您需要动态生成卡片主题,可以使用接受两个参数 - $message$levelmessage() 方法。

->info($message)
->success($message)
->warning($message)
->danger($message)
->message($message, $level) // accepted values for $level: 'info', 'success' , 'warning', 'danger'

Example

定义标题

您还可以使用 heading() 方法为消息定义标题。

(new Info())
    ->heading('Info heading')
    ->info('Some info message')

Heading screenshot

渲染HTML

如果您想将消息以纯HTML形式渲染,就像Nova允许您在资源字段中做的那样,只需链式调用 asHtml() 方法。

(new Info())
    ->info('Be sure to like this package and give us your feedback in
    <a href="https://github.com/pdmfc/nova-info-card/" class="underline font-bold text-blue-800">our repository</a>!')
    ->asHtml(),

Rendering raw Html

如何贡献

  • 克隆仓库
  • 在Laravel Nova应用程序的 composer.json 中添加以下内容
{
    //...

    "require" {
        "pdmfc/nova-info-card: "*"
    },

    //...
    "repositories": [
        {
            "type": "path",
            "url": "../path_to_your_package_folder"
        }
    ],
}
  • 运行 composer update pdmfc/nova-info-card

现在您可以开始贡献了!