gfhack / cpfcnpj-laravel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cpfcnpj-laravel

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

Instalação Composer

$ composer require eltoninacio/cpfcnpj-laravel

ou

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

Configuração Laravel

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

'providers' => [
	// ...
    EltonInacio\ValidadorCpjCnpj\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'
		];
	}

}

About


Languages

Language:PHP 100.0%