项目作者: freshworkstudio

项目描述 :
Campo RUT para Laravel Nova / Chilean RUT field for Laravel Nova
高级语言: Vue
项目地址: git://github.com/freshworkstudio/nova-rut-field.git
创建时间: 2018-10-01T05:42:24Z
项目社区:https://github.com/freshworkstudio/nova-rut-field

开源协议:Other

下载


RUT Field for Laravel Nova

This package adds a Chilean RUT Field to Laravel Nova.
It uses this composer package behind the scenes.

  • Formats the input text on keyup or blur
  • Normalizes the format before storing the value on database (without dashes nor dots). You can disable this and store the original text sended by the user.
  • Can validate the value.

Getting started RutField

  1. use Freshwork\RutField\RutField;
  2. // ...
  3. public function fields(Request $request)
  4. {
  5. return [
  6. RutField::make('rut')->rules('required|cl_rut');
  7. ]
  8. }

When to format

By defaultm, on forms, it format the value on keyup. You can change this to blur.

  1. RutField::make('rut')->formatOnBlur();

The format

There are three possible formats:

  1. COMPELTE 12.345.678-9
  2. WITH DASH 12345678-9
  3. ESCAPED 123456789

By default COMPLETE format is used, but you can change it.

  1. RutField::make('rut')->formatComplete();
  2. RutField::make('rut')->formatWithDash();
  3. RutField::make('rut')->formatEscaped();

Validation

As you can check on this composer package, you can use cl_rut laravel validation.
If you need a custom validation error, you can override your resources/lang/es/validation.php. I personally use this package: https://github.com/caouecs/Laravel-lang

  1. RutField::make('rut')->rules('required|cl_rut');

Normalize on save

By default, the RUT value is always escaped (ESCAPED format) before saving to database. You can change this with saveWithoutNormalization saving the same text written by the user on the text field.

  1. RutField::make('rut')->saveWithoutNormalization();

Format the field as Chilean RUT/DNI.

Also, you can validate the field using ‘cl_rut’ laravel validation included on this package:
https://github.com/freshworkstudio/ChileanBundle

Screenshot