src/LaravelPanel/controllers/PanelController.php
private function validationRules($fields, $edit = false)
    {
        $validationRules = [];

        // Go through each field to find validation rules
        foreach ($fields as $name => $options) {
            if (isset($options['validate'])) {
                $validationRules[$name] = $options['validate'];

                // Change validation rules if there's validations as edit
                if ($edit && isset($options['validateAtEdit'])) {
                    $validationRules[$name] = $options['validateAtEdit'];
                }

                if ($options['type'] == 'image') {
                    $rules = explode('|', $validationRules[$name]);

                    // If there isn't a validation rule for the image, add it
                    if (!in_array('image', $rules)) {
                        $rules[] = 'image';
                    }

                    $validationRules[$name] = implode('|', $rules);
                }
            }
        }

        return $validationRules;
    }
private function validationRules($fields, $edit = false)
    {
        $validationRules = [];

        // Go through each field to find validation rules
        foreach ($fields as $name => $options) {
            if (isset($options['validate'])) {
                $validationRules[$name] = $options['validate'];

                // Change validation rules if there's validations as edit
                if ($edit && isset($options['validateAtEdit'])) {
                    $validationRules[$name] = $options['validateAtEdit'];
                }

                if ($options['type'] == 'image') {
                    $rules = explode('|', $validationRules[$name]);

                    // If there isn't a validation rule for the image, add it
                    if (!in_array('image', $rules)) {
                        $rules[] = 'image';
                    }

                    $validationRules[$name] = implode('|', $rules);
                }
            }
        }

        return $validationRules;
    }
private function validationRules ( $ fields , $ edit = false ) { $ validationRules = [ ] ; // Go through each field to find validation rules foreach ( $ fields as $ name => $ options ) { if ( isset ( $ options [ 'validate' ] ) ) { $ validationRules [ $ name ] = $ options [ 'validate' ] ; // Change validation rules if there's validations as edit if ( $ edit && isset ( $ options [ 'validateAtEdit' ] ) ) { $ validationRules [ $ name ] = $ options [ 'validateAtEdit' ] ; } if ( $ options [ 'type' ] == 'image' ) { $ rules = explode ( '|' , $ validationRules [ $ name ] ) ; // If there isn't a validation rule for the image, add it if ( ! in_array ( 'image' , $ rules ) ) { $ rules [ ] = 'image' ; } $ validationRules [ $ name ] = implode ( '|' , $ rules ) ; } } } return $ validationRules ; }
Return the validation rules for each field.

@param array $fields Array of fields
@param bool  $edit   If it needs to read additional rules at edit

@return string
Return the validation rules for each field .