定制 mlsolutions/masked-field 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mlsolutions/masked-field

最新稳定版本:v1.1

Composer 安装命令:

composer require mlsolutions/masked-field

包简介

A Laravel Nova field.

README 文档

README

Docker development

Build the development container:

docker compose build

Install PHP and JavaScript dependencies. Run Composer first because the frontend build imports Nova mixins from vendor/laravel/nova:

docker compose run --rm app composer install
docker compose run --rm app npm install

Build or watch the Nova field assets:

docker compose run --rm app npm run dev
docker compose run --rm app npm run prod
docker compose run --rm app npm run watch

If your host user is not UID/GID 1000, pass your IDs when building so generated files are writable outside the container:

UID=$(id -u) GID=$(id -g) docker compose build

This package depends on laravel/nova, so composer install may require your Nova Composer credentials.

Installation

composer require mlsolutions/masked-field

Basic Usage

To use the Laravel Nova Masked Field, follow these steps:

  1. Import the MaskedField class in your Nova resource file:
use Mlsolutions\MaskedField\MaskedField;
  1. Add the MaskedField to the fields method of your resource file:
public function fields(Request $request)
{
    return [
        MaskedField::make('Phone')
            ->mask('(###) ###-####'),
    ];
}
  1. Optional - Save Value Without Mask
    If you want to store the raw (unmasked) value in the database, use the raw() method:
MaskedField::make('Phone')
    ->mask('(###) ###-####')
    ->raw(),

masked-field-demo

Usage with dependsOn

You can also use the dependsOn method to set a conditional mask based on the value of another field. Here's an example:

use Mlsolutions\MaskedField\MaskedField;

public function fields(Request $request)
{
    return [
        MaskedField::make('Phone', 'phone')
            ->mask('(###) ###-####')
            ->dependsOn(['country'], function (MaskedField $field, NovaRequest $request, FormData $formData) {
                if($formData->country == 'BR')
                    $field->mask('(##) ####-####');
            })
    ];
}

On Laravel Nova 5, this field emits value changes through Nova's dependent field flow, so it can both react to dependsOn updates and be used as the source field for other dependent fields.

Mask syntax

The Laravel Nova Masked Field uses a mask syntax to define patterns for input formatting. Here are the default tokens available:

{
    '#': { pattern: /[0-9]/ },
    'X': { pattern: /[0-9a-zA-Z]/ },
    'S': { pattern: /[a-zA-Z]/ },
    'A': { pattern: /[a-zA-Z]/, uppercase: true },
    'a': { pattern: /[a-zA-Z]/, lowercase: true },
    '!': { escape: true },
    '*': { repeat: true }
}

You can refer to the beholdr/maska repository for more information on the mask syntax.

References

Notice Regarding Nova License

Hey everyone,

My Nova license expired in November 2023 for version v4.29.2, which is the last version I have access to. Currently, I don't have plans to renew it, so unfortunately, I won't be able to assist with issues related to updates or newer Nova features. Feel free to seek alternative support or solutions with other users or maintainers.

Thank you for your understanding.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 7
  • 开发语言: Vue

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固