protected static function gatherRules()
    {
        // This rather gnarly looking logic is just for developer convenience
        // so he can define multiple rule groups on the model for clarity
        // and now we simply gather all rules and merge them together.
        $keys = static::getValidatedFields();

        $result = array_fill_keys($keys, []);

        foreach ($keys as $key) {
            foreach (static::getRulesGroups() as $groupName) {
                $group = static::getRulesGroup($groupName);

                if (isset($group[$key])) {
                    $rules = is_array($group[$key])
                            ? $group[$key]
                            : explode('|', $group[$key]);

                    foreach ($rules as &$rule) {
                        if ($rule === 'unique') {
                            $table = (new static)->getTable();

                            $rule .= ":{$table}";
                        }
                    }

                    unset($rule);

                    $result[$key] = array_unique(array_merge($result[$key], $rules));
                }
            }
        }

        return $result;
    }
protected static function gatherRules()
    {
        // This rather gnarly looking logic is just for developer convenience
        // so he can define multiple rule groups on the model for clarity
        // and now we simply gather all rules and merge them together.
        $keys = static::getValidatedFields();

        $result = array_fill_keys($keys, []);

        foreach ($keys as $key) {
            foreach (static::getRulesGroups() as $groupName) {
                $group = static::getRulesGroup($groupName);

                if (isset($group[$key])) {
                    $rules = is_array($group[$key])
                            ? $group[$key]
                            : explode('|', $group[$key]);

                    foreach ($rules as &$rule) {
                        if ($rule === 'unique') {
                            $table = (new static)->getTable();

                            $rule .= ":{$table}";
                        }
                    }

                    unset($rule);

                    $result[$key] = array_unique(array_merge($result[$key], $rules));
                }
            }
        }

        return $result;
    }
protected static function gatherRules ( ) { // This rather gnarly looking logic is just for developer convenience // so he can define multiple rule groups on the model for clarity // and now we simply gather all rules and merge them together. $ keys = static :: getValidatedFields ( ) ; $ result = array_fill_keys ( $ keys , [ ] ) ; foreach ( $ keys as $ key ) { foreach ( static :: getRulesGroups ( ) as $ groupName ) { $ group = static :: getRulesGroup ( $ groupName ) ; if ( isset ( $ group [ $ key ] ) ) { $ rules = is_array ( $ group [ $ key ] ) ? $ group [ $ key ] : explode ( '|' , $ group [ $ key ] ) ; foreach ( $ rules as & $ rule ) { if ( $ rule === 'unique' ) { $ table = ( new static ) -> getTable ( ) ; $ rule .= ":{$table}" ; } } unset ( $ rule ) ; $ result [ $ key ] = array_unique ( array_merge ( $ result [ $ key ] , $ rules ) ) ; } } } return $ result ; }
Gather all the rules for the model and store it for easier use.

@return array
Gather all the rules for the model and store it for easier use .