Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

eltoninacio/cpfcnpj-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cpfcnpj-laravel

Validação de cpf, cnpj, cpfcnpj para laravel 5.*

Instalação Composer

$ composer require eltoninacio/cpfcnpj-laravel

ou

"require": {
    "eltoninacio/cpfcnpj-laravel": "2.0.*"
}
$ composer update

Configuração Laravel

Registre o ServiceProvider no array providers dentro do arquivo config/app.php:

'providers' => [
	// ...
    EltonInacio\ValidadorCpfCnpj\CpfCnpjServiceProvider::class
]

Exemplo de uso

$this->validade($request, [
    'cpf'       => 'cpf',
    'cnpj'      => 'cnpj',
    'cpfcnpj'   => 'cpfcnpj'
])

ou

namespace App\Http\Requests;

use App\Http\Requests\Request;

class CpfCnpjRequest extends Request {

	/**
	 * Determine if the user is authorized to make this request.
	 *
	 * @return bool
	 */
	public function authorize()
	{
		return true;
	}

	/**
	 * Get the validation rules that apply to the request.
	 *
	 * @return array
	 */
	public function rules()
	{
		return [
			'cpf' 		=> 'cpf',
			'cnpj'		=> 'cnpj',
			'cpfcnpj'	=> 'cpfcnpj'
		];
	}

}