PHP code example of szunisoft / laravel-rule-groups
1. Go to this page and download the library: Download szunisoft/laravel-rule-groups library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use SzuniSoft\RuleGroups\RuleGroup;
class CompanyRuleGroup extends RuleGroup {
protected function getAttributeRules() {
// Here we go..
return [
// This is self explained
'name' => ['d.
'phone' => new MyVeryCustomAndFavoritePhoneRule(),
// Laravel built in Rule is welcomed too
'country' => ['
public function register(Request $request) {
$this->validate($request, CompanyRuleGroup::rules());
// Further secret business logic..
}
public function register(Request $request) {
$this->validate($request, [
'name' => ['e(),
'country' => ['
use SzuniSoft\RuleGroups\RuleGroup;
class CompanyRuleGroup extends RuleGroup {
protected function getAttributeRules() {
return [
'name' => ['', 'iso_2')],
'state' => ['
public function register (Request $request) {
$this->validate($request, array_merge(
CompanyRuleGroup::attributes()->prefixed('managed')->toArray(),
CompanyRuleGroup::attributes()->prefixed('billed')->toArray(),
));
}
public function register (Request $request) {
$this->validate($request, array_merge(
CompanyRuleGroup::attributes()->prefixed('managed')->toArray(),
CompanyRuleGroup::attributes()
// Adds rule(s) to all attribute in the group
->addToAll('