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;
        });
    }
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;
        });
    }
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 ; } ) ; }
Add the moment extension to the builder.

@param  \Illuminate\Database\Eloquent\Builder  $builder
@return void
Add the moment extension to the builder .