Download the PHP package alvarofpp/masks without Composer
On this page you can find all versions of the php package alvarofpp/masks. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alvarofpp/masks
More information about alvarofpp/masks
Files in alvarofpp/masks
Package masks
Short Description A package to mask your variables or model's attributes.
License MIT
Homepage https://github.com/alvarofpp/laravel-masks
Informations about the package masks
masks
A package to mask your variables or model's attributes.
Contents
- Install
- Usage
- Contributing
Install
Install via composer:
Usage
This package currently contains:
- Mask helper.
- Applies mask in model's attributes.
Mask helper
mask(string $mask, string $value): string
You can use this helper to apply mask in any value that you want. Example:
Applies mask in model's attributes
You can use the trait MaskAttributes
in your model to apply masks in the attributes.
Taking the example in the previous section, we can automate the masks such as:
So if the value of $user->cpf
is 12345678901
, you can use $user->cpf_masked
to take the value masked.
In the $user->phone
case, the mask will depend on the length of the value, for example:
if phone has 1234567890
, the value masked will be (12) 3456-7890
,
but if phone has 12345678901
, the value masked will be (12) 345-678-901
.
By default, MaskAttributes
use the suffix _masked
, you can change the suffix declaring $maskSuffix
:
That way, you use $user->cpf_formatted
to grab the masked value.
Contributing
Contributions are more than welcome. Fork, improve and make a pull request. For bugs, ideas for improvement or other, please create an issue.