joshmoreno/nova-html-field

一个Laravel Nova字段,用于在索引、详情和表单上渲染自定义HTML。


README

一个用于在所有资源页面(索引、详情和表单)上渲染HTML的nova字段。这可能是nova支持表单上的计算字段之前的一个临时解决方案。

安装

composer require joshmoreno/nova-html-field

使用方法

内联字符串

\JoshMoreno\Html\Html::make('Some Title')
    ->html('<h1>Example</h1>'),

闭包

\JoshMoreno\Html\Html::make('Some Title')
    ->html(function() {
        return "<h1>$this->name</h1>";
    }),

视图

\JoshMoreno\Html\Html::make('Some Title')
    ->view('fields.example'),
<div class="px-8 py-6 border-b border-40">
    <h1 class="mb-2">Custom Html</h1>
    <p>This is all custom html!</p>
</div>

带有模型属性访问权限的视图

\JoshMoreno\Html\Html::make('Some Title')
    ->html(function() {
        return view('fields.example')
                 ->with('name', $this->name)
                 ->render();
    }),
<div class="px-8 py-6 border-b border-40">
    <h1 class="mb-2">Hi {{$name}}</h1>
    <p>This is all custom html with data!</p>
</div>