classes/Models/Traits/Loggable.php
private static function builderMatchesChange(Change $change, Builder $builder)
    {
        $class = $change->model;
        $route_key_name = (new $class)->getRouteKeyName();
        return collect($builder->getQuery()->wheres)
            ->contains(function($where) use ($change, $route_key_name) {

                // If the builder is keyed to a simple "id" in the route, return
                // whether the Change matches it.
                if ($route_key_name == 'id') {
                    return $where['column'] == $route_key_name
                        && $where['operator'] == '='
                        && $where['value'] == $change->key;

                // Otherwise compare against model logged by the change. The
                // scope needs to be removed to prevent recursion.
                } else {
                    $value = $change->changedModel()
                        ->withoutGlobalScope(static::$LOGGABLE_SCOPE)
                        ->first()
                        ->$route_key_name;
                    return $where['column'] == $route_key_name
                        && $where['operator'] == '='
                        && $where['value'] == $value;
                }
        });
    }
private static function builderMatchesChange(Change $change, Builder $builder)
    {
        $class = $change->model;
        $route_key_name = (new $class)->getRouteKeyName();
        return collect($builder->getQuery()->wheres)
            ->contains(function($where) use ($change, $route_key_name) {

                // If the builder is keyed to a simple "id" in the route, return
                // whether the Change matches it.
                if ($route_key_name == 'id') {
                    return $where['column'] == $route_key_name
                        && $where['operator'] == '='
                        && $where['value'] == $change->key;

                // Otherwise compare against model logged by the change. The
                // scope needs to be removed to prevent recursion.
                } else {
                    $value = $change->changedModel()
                        ->withoutGlobalScope(static::$LOGGABLE_SCOPE)
                        ->first()
                        ->$route_key_name;
                    return $where['column'] == $route_key_name
                        && $where['operator'] == '='
                        && $where['value'] == $value;
                }
        });
    }
private static function builderMatchesChange ( Change $ change , Builder $ builder ) { $ class = $ change -> model ; $ route_key_name = ( new $ class ) -> getRouteKeyName ( ) ; return collect ( $ builder -> getQuery ( ) -> wheres ) -> contains ( function ( $ where ) use ( $ change , $ route_key_name ) { // If the builder is keyed to a simple "id" in the route, return // whether the Change matches it. if ( $ route_key_name == 'id' ) { return $ where [ 'column' ] == $ route_key_name && $ where [ 'operator' ] == '=' && $ where [ 'value' ] == $ change -> key ; // Otherwise compare against model logged by the change. The // scope needs to be removed to prevent recursion. } else { $ value = $ change -> changedModel ( ) -> withoutGlobalScope ( static :: $ LOGGABLE_SCOPE ) -> first ( ) -> $ route_key_name ; return $ where [ 'column' ] == $ route_key_name && $ where [ 'operator' ] == '=' && $ where [ 'value' ] == $ value ; } } ) ; }
Does the Change referenced in the GET query match the conditions already
applied in the query builder?

@param  Change $change
@param  Builder $builder
@return boolean
Does the Change referenced in the GET query match the conditions already applied in the query builder?