everzel / nova-charcounted-fields
带字符计数的文本和文本区域字段。
dev-main
2023-05-11 17:30 UTC
Requires
- php: >=7.1.0
This package is not auto-updated.
Last update: 2024-09-27 21:58:15 UTC
README
为Laravel Nova提供带字符计数的文本和文本区域字段。
安装
将GitHub URL添加到你的composer.json
仓库列表中
"repositories": [
{
"type": "vcs",
"url": "git@github.com:optimistdigital/nova-charcounted-fields.git"
}
]
你可以使用Composer来要求这个包
composer require everzel/nova-charcounted-fields
用法
你可以按照以下方式添加具有解析器的字段
use Everzel\CharcountedFields\TextCounted;
use Everzel\CharcountedFields\TextareaCounted;
TextCounted::make('Meta title')
你可以在你的Nova模型上使用带有字符计数的文本和文本区域字段。最大字符数不是强制性的,但通过警告颜色和计数器来鼓励。(你可以通过Nova内置的rules和maxlength额外属性来强制最大字符数)。
TextCounted::make('Meta title') ->maxChars(60) ->warningAt(50) ->withMeta(['extraAttributes' => ['maxlength' => '65']]), TextareaCounted::make('Meta description') ->maxChars(160) ->warningAt(150) ->rows(3),