everzel/nova-charcounted-fields

带字符计数的文本和文本区域字段。

dev-main 2023-05-11 17:30 UTC

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')

Image of character counter

你可以在你的Nova模型上使用带有字符计数的文本和文本区域字段。最大字符数不是强制性的,但通过警告颜色和计数器来鼓励。(你可以通过Nova内置的rulesmaxlength额外属性来强制最大字符数)。

TextCounted::make('Meta title')
    ->maxChars(60)
    ->warningAt(50)
    ->withMeta(['extraAttributes' => ['maxlength' => '65']]),

TextareaCounted::make('Meta description')
    ->maxChars(160)
    ->warningAt(150)
    ->rows(3),

maxChars和warningAt都是可选的。当达到最大或警告At限制时,计数器的颜色将改变。 字符计数器指示图