reedware / nova-textwrap-field
为 Laravel Nova 添加一个具有换行功能的文本字段。
v1.0.0
2019-10-31 15:40 UTC
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-09-07 20:47:41 UTC
README
安装
您可以通过 composer 将此软件包安装到使用 Nova 的 Laravel 应用中。
composer require reedware/nova-textwrap-field
用法
创建一个新字段,就像创建其他任何字段一样
<?php namespace App\Nova; use Reedware\NovaTextwrapField\TextWrap; class MyResource extends TextFilter { /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request, $query, $value) { return [ TextWrap::make('My Field', my_field') ]; } }
选项
TextWrap
字段扩展了默认的 TextArea
字段,因此任何在 TextArea
上可用的选项也在 TextWrap
上可用。此外,TextWrap
字段默认配置为在索引页上显示(而 TextArea
则不显示)。
还有两个额外的选项
- Markdown:
TextWrap::make(...)->asMarkdown()
将解析并显示为 markdown 格式的内容 - 最大宽度:
TextWrap::make(...)->withMeta('maxWidth' => '...')
将对字段内容强制执行最大宽度
外观
以下是一个我在实际中使用的例子