jorge / custom-cakephp3
CakePHP 3 Custom
Installs: 2 476
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=5.4.16
- cakephp/cakephp: ~3.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-10-28 14:51:20 UTC
README
Instalação
<?php Plugin::load("JCustomCakephp3");
Como usar
1. Ajuste dos campos de data para o formato SQL americano.
Add no Model:
<?php class PostsTable extends Table { public function initialize($config = []) { $this->addBehavior("JCustomCakephp3.ConvertDate"); } }
ou
<?php class PostsTable extends Table { public function initialize($config = []) { $this->addBehavior("JCustomCakephp3.ConvertDate", ['fild_name1', 'fild_name2']); } }
2. Validação de dados brasileiros.
Add no Model no método validationDefault():
<?php public function validationDefault(Validator $validator) { $validator ->provider('custom', new \JCustomCakephp3\Validation\CustomProvider) ->add('birth', 'valid', ['rule' => 'dateBR', 'provider' => 'custom']) ->requirePresence('birth', 'create') ->notEmpty('birth'); }
Rules:
- dateBR
- datetimeBR
- cnpj
- cpf
- cep
- phone
- cellphone