public static function parseModel($parameters, $model)
    {
        if (is_object($parameters)) {
            $parameters = (array)$parameters;
        }

        $required_fields = [];
        foreach ($model as $key => $value) {
            if (in_array('required', $value, true) === true
                || in_array('required', $value, true) == true) {
                $required_fields[] = $key;
            }
        }

        Request::requireParameters($parameters, $required_fields);
        \Phramework\Validate\Validate::model($parameters, $model);

        $keys_values = [];
        foreach ($model as $key => $value) {
            if (isset($parameters[$key])) {
                if (in_array('nullable', $value) && $parameters[$key] == '0') {
                    $keys_values[$key] = null;
                    continue;
                }
                //Set value as null
                if (in_array('nullable', $value) && !$parameters[$key]) {
                    $keys_values[$key] = null;
                    continue;
                }
                /*
                if ($value['type'] == 'select' && !$parameters[$key]) {
                    $keys_values[$key] = NULL;
                } else {*/
                    $keys_values[$key] = $parameters[$key];
                /*}*/
            } elseif (($value['type'] == 'boolean' || in_array('boolean', $value))
                && (!isset($parameters[$key]) || !$parameters[$key])) {
                $keys_values[$key] = false;
            }
        }

        return $keys_values;
    }
public static function parseModel($parameters, $model)
    {
        if (is_object($parameters)) {
            $parameters = (array)$parameters;
        }

        $required_fields = [];
        foreach ($model as $key => $value) {
            if (in_array('required', $value, true) === true
                || in_array('required', $value, true) == true) {
                $required_fields[] = $key;
            }
        }

        Request::requireParameters($parameters, $required_fields);
        \Phramework\Validate\Validate::model($parameters, $model);

        $keys_values = [];
        foreach ($model as $key => $value) {
            if (isset($parameters[$key])) {
                if (in_array('nullable', $value) && $parameters[$key] == '0') {
                    $keys_values[$key] = null;
                    continue;
                }
                //Set value as null
                if (in_array('nullable', $value) && !$parameters[$key]) {
                    $keys_values[$key] = null;
                    continue;
                }
                /*
                if ($value['type'] == 'select' && !$parameters[$key]) {
                    $keys_values[$key] = NULL;
                } else {*/
                    $keys_values[$key] = $parameters[$key];
                /*}*/
            } elseif (($value['type'] == 'boolean' || in_array('boolean', $value))
                && (!isset($parameters[$key]) || !$parameters[$key])) {
                $keys_values[$key] = false;
            }
        }

        return $keys_values;
    }
public static function parseModel ( $ parameters , $ model ) { if ( is_object ( $ parameters ) ) { $ parameters = ( array ) $ parameters ; } $ required_fields = [ ] ; foreach ( $ model as $ key => $ value ) { if ( in_array ( 'required' , $ value , true ) === true || in_array ( 'required' , $ value , true ) == true ) { $ required_fields [ ] = $ key ; } } Request :: requireParameters ( $ parameters , $ required_fields ) ; \ Phramework \ Validate \ Validate :: model ( $ parameters , $ model ) ; $ keys_values = [ ] ; foreach ( $ model as $ key => $ value ) { if ( isset ( $ parameters [ $ key ] ) ) { if ( in_array ( 'nullable' , $ value ) && $ parameters [ $ key ] == '0' ) { $ keys_values [ $ key ] = null ; continue ; } //Set value as null if ( in_array ( 'nullable' , $ value ) && ! $ parameters [ $ key ] ) { $ keys_values [ $ key ] = null ; continue ; } /*
                if ($value['type'] == 'select' && !$parameters[$key]) {
                    $keys_values[$key] = NULL;
                } else {*/ $ keys_values [ $ key ] = $ parameters [ $ key ] ; /*}*/ } elseif ( ( $ value [ 'type' ] == 'boolean' || in_array ( 'boolean' , $ value ) ) && ( ! isset ( $ parameters [ $ key ] ) || ! $ parameters [ $ key ] ) ) { $ keys_values [ $ key ] = false ; } } return $ keys_values ; }
Required required values and parse provided parameters into an array
Validate the provided request model and return the
@uses \Phramework\Models\Request::requireParameters
@param array|object $parameters
@param array $model
@return array Return the keys => values collection
@deprecated since 1.0.0
Required required values and parse provided parameters into an array Validate the provided request model and return the