protected function addMoment(Builder $builder)
    {
        $builder->macro('moment', function(Builder $builder, Carbon $moment) {
            $model = $builder->getModel();

            $this->remove($builder, $builder->getModel());

            $builder->join($model->getVersionTable(), function($join) use ($model, $moment) {
                $join->on($model->getQualifiedKeyName(), '=', $model->getQualifiedVersionKeyName());
                $join->where('updated_at', '<=', $moment)->orderBy('updated_at', 'desc')->limit(1);
            })->orderBy('updated_at', 'desc')->limit(1);

            return $builder;
        });
    }