protected function isOrdered(array $ordered)
    {

        // validate fields by exist in tables

        foreach ($ordered as $table => $sort) {

            // load model metaData

            if ($this->isModel($table) === true) {
                $model = (new Manager())->load($table, new $table);

                // check fields of table

                $this->validColumns($model->getModelsMetaData(), array_keys($sort), $table, $model);

                // check sort clause

                $sort = array_map('strtolower', $sort);

                if (empty($diff = array_diff(array_values($sort), $this->sort)) === false) {
                    throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
                }

                if (empty($diff = array_diff($sort, $this->sort)) === false) {
                    throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
                }

                $this->fields[$this->cast][$model->getSource()] = $sort;
            }
        }

        return true;
    }
protected function isOrdered(array $ordered)
    {

        // validate fields by exist in tables

        foreach ($ordered as $table => $sort) {

            // load model metaData

            if ($this->isModel($table) === true) {
                $model = (new Manager())->load($table, new $table);

                // check fields of table

                $this->validColumns($model->getModelsMetaData(), array_keys($sort), $table, $model);

                // check sort clause

                $sort = array_map('strtolower', $sort);

                if (empty($diff = array_diff(array_values($sort), $this->sort)) === false) {
                    throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
                }

                if (empty($diff = array_diff($sort, $this->sort)) === false) {
                    throw new ExceptionFactory('Column', ['ORDER_TYPES_DOES_NOT_EXISTS', $diff]);
                }

                $this->fields[$this->cast][$model->getSource()] = $sort;
            }
        }

        return true;
    }
protected function isOrdered ( array $ ordered ) { // validate fields by exist in tables foreach ( $ ordered as $ table => $ sort ) { // load model metaData if ( $ this -> isModel ( $ table ) === true ) { $ model = ( new Manager ( ) ) -> load ( $ table , new $ table ) ; // check fields of table $ this -> validColumns ( $ model -> getModelsMetaData ( ) , array_keys ( $ sort ) , $ table , $ model ) ; // check sort clause $ sort = array_map ( 'strtolower' , $ sort ) ; if ( empty ( $ diff = array_diff ( array_values ( $ sort ) , $ this -> sort ) ) === false ) { throw new ExceptionFactory ( 'Column' , [ 'ORDER_TYPES_DOES_NOT_EXISTS' , $ diff ] ) ; } if ( empty ( $ diff = array_diff ( $ sort , $ this -> sort ) ) === false ) { throw new ExceptionFactory ( 'Column' , [ 'ORDER_TYPES_DOES_NOT_EXISTS' , $ diff ] ) ; } $ this -> fields [ $ this -> cast ] [ $ model -> getSource ( ) ] = $ sort ; } } return true ; }
Check ordered fields

@param  array            $ordered
@throws ExceptionFactory
@return boolean
Check ordered fields