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/ */

    

szunisoft / laravel-rule-groups example snippets


'providers' => [
    ...
    
    /*
     * Package Service Providers...
     */
     \SzuniSoft\RuleGroups\Providers\RuleGroupServiceProvider::class
]

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, [
        
        'managed.name' => ['ule(),
        'managed.country' => [',
        'managed.address' => ['untry' => ['250'],
    
    ]);

}

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('
config/app.php

php artisan vendor:publish --provider="\SzuniSoft\RuleGroups\Providers\RuleGroupServiceProvider" --tag="config"