rmsramos/postal-code

与 ViaCep 集成的 CEP 集成

v0.1.1 2024-06-04 18:22 UTC

This package is auto-updated.

Last update: 2024-09-04 18:56:57 UTC


README

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

此软件包提供与 ViaCep 集成的 Filament 自定义表单字段。

安装

您可以通过 composer 安装此软件包。

composer require rmsramos/postal-code

用法

use Filament\Forms\Components\TextInput;
use Rmsramos\PostalCode\Components\PostalCode;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            PostalCode::make('postal_code')
                ->viaCep(
                    errorMessage: 'CEP inválido.', // Custom message to display if the CEP is invalid.
                    setFields: [
                        'street'        => 'logradouro',
                        'number'        => 'numero',
                        'complement'    => 'complemento',
                        'district'      => 'bairro',
                        'city'          => 'localidade',
                        'state'         => 'uf'
                    ]
                ),

            TextInput::make('street'),
            TextInput::make('number')
                 ->extraAlpineAttributes([
                     'x-on:cep.window' => "\$el.focus()",
                 ]),,
            TextInput::make('complement'),
            TextInput::make('district'),
            TextInput::make('city'),
            TextInput::make('state'),
        ])
}

测试

composer test

变更日志

有关最近更改的更多信息,请参阅 变更日志

贡献

有关详细信息,请参阅 贡献指南

安全漏洞

请审查 我们的安全策略 了解如何报告安全漏洞。

致谢

许可证

MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件