Wallogit.com
2017 © Pedro Peláez
Do action and filters with Herbert
Add the bellow piece of code in plugin.php to set $app in Facade, (*1)
if ( is_plugin_active(plugin_basename( __FILE__ )) ) {, (*2)
$plugin = new \Herbert\Framework\Base\Plugin(plugin_dir_path( __FILE__ ));, (*3)
$herbert->registerPlugin($plugin);, (*4)
$app = $plugin->getContainer();, (*5)
FlycartValidator\Facades\Facade::setFacadeApplication($app);, (*6)
}, (*7)
Add the bellow piece of code in herbert.config.php to load FlycartHook service provider, (*8)
'providers' => array(, (*9)
FlycartValidator\ValidationServiceProvider::class, (*10)
), (*11)
# Flycart Validator Example, (*12)
Validate single data, (*13)
$data = \FlycartValidator\Facades\Validator::single($data, ['num', 'min:3']), (*14)
Validate multiple data, (*15)
$data = \FlycartValidator\Facades\Validator::multiple($data, [
'field-name' => ['alnum', 'min:5'],
'email' => ['email'],
'age' => ['num']
]);, (*16)
returns empty value for the key failed else the value as send., (*17)