https://github.com/mpijierro/identity
Componente for Laravel to check valid spanish document id as NIF, CIF y NIE
https://github.com/mpijierro/identity
laravel nif php
Last synced: 6 months ago
JSON representation
Componente for Laravel to check valid spanish document id as NIF, CIF y NIE
- Host: GitHub
- URL: https://github.com/mpijierro/identity
- Owner: mpijierro
- License: mit
- Created: 2017-02-18T23:39:40.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-07-07T07:10:51.000Z (almost 6 years ago)
- Last Synced: 2024-08-09T01:42:17.889Z (almost 2 years ago)
- Topics: laravel, nif, php
- Language: PHP
- Homepage:
- Size: 43.9 KB
- Stars: 7
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Identity for Laravel/Lumen ^5.1|6.X
Check valid spanish document id as NIF, CIF, NIE and IBAN back account.
## Installation
Laravel 5.8 or greather => master
Laravel 5.1 to 5.7 => 1.1.0
Require this package with composer:
Add in the require section of your composer.json
```
composer require mpijierro/identity
```
### Laravel/Lumen
```php
\MPijierro\Identity\IdentityServiceProvider::class,
```
If you want to use the facade, add this to your facades in app.php:
```php
'Identity' => MPijierro\Identity\Facades\Identity::class,
```
Note: Branch 1.1 has a modification in which the default error messages have been removed. If you use this branch, you must add the validation messages you want to your language file.
## Usage
You can now check document ide using the Facade (when added)
```php
Identity::isValidCif('1234foo');
Identity::isValidNif('1234foo');
Identity::isValidNie('1234foo');
Identity::isValidIban('1234foo');
Identity::isValidNNSS('1234foo');
```
methods returns true or false
It is also possible to use **validation rules**:
```php
'nif_field' => 'nif'
'cif_field' => 'cif'
'nie_field' => 'nie'
'iban_field' => 'iban'
'nnss_field' => 'nnss'
```
If error ocurred, error message will be:
```php
"The $foo_attribute field is not a valid Foo.";
```
## Thanks
The original code for NIF, CIF AND NIE is in next link
http://www.michublog.com/informatica/8-funciones-para-la-validacion-de-formularios-con-expresiones-regulares
Thanks to original code of: globalcitizen/php-iban
https://github.com/globalcitizen/php-iban
Thanks to original code for the validation of the NNSS of: http://intervia.com
http://intervia.com/doc/validar-numeros-de-la-seguridad-social/