public function getNextSortValue(array $scope = []): int
    {
        $query = $this->_table->query();
        $scope = Hash::merge($this->getConfig('scope'), $scope);
        if (!empty($scope)) {
            $query->where($scope);
        }
        $query->select([
            'maxSort' => $query->func()->max($this->getConfig('sortField')),
        ]);
        $res = $query->enableHydration(false)->first();
        if (empty($res)) {
            return 1;
        }

        return ($res['maxSort'] + 1);
    }
public function getNextSortValue(array $scope = []): int
    {
        $query = $this->_table->query();
        $scope = Hash::merge($this->getConfig('scope'), $scope);
        if (!empty($scope)) {
            $query->where($scope);
        }
        $query->select([
            'maxSort' => $query->func()->max($this->getConfig('sortField')),
        ]);
        $res = $query->enableHydration(false)->first();
        if (empty($res)) {
            return 1;
        }

        return ($res['maxSort'] + 1);
    }
public function getNextSortValue ( array $ scope = [ ] ) : int { $ query = $ this -> _table -> query ( ) ; $ scope = Hash :: merge ( $ this -> getConfig ( 'scope' ) , $ scope ) ; if ( ! empty ( $ scope ) ) { $ query -> where ( $ scope ) ; } $ query -> select ( [ 'maxSort' => $ query -> func ( ) -> max ( $ this -> getConfig ( 'sortField' ) ) , ] ) ; $ res = $ query -> enableHydration ( false ) -> first ( ) ; if ( empty ( $ res ) ) { return 1 ; } return ( $ res [ 'maxSort' ] + 1 ) ; }
Returns the next highest sort value

@param array $scope Optional conditions
@return int
Returns the next highest sort value