src/ModelFilter.php
private function registerMacros()
    {
        if (
            method_exists(Relation::class, 'hasMacro') &&
            method_exists(Relation::class, 'macro') &&
            ! Relation::hasMacro('paginateFilter') &&
            ! Relation::hasMacro('simplePaginateFilter')
        ) {
            Relation::macro('paginateFilter', function () {
                $paginator = call_user_func_array([$this, 'paginate'], func_get_args());
                $paginator->appends($this->getRelated()->filtered);

                return $paginator;
            });
            Relation::macro('simplePaginateFilter', function () {
                $paginator = call_user_func_array([$this, 'simplePaginate'], func_get_args());
                $paginator->appends($this->getRelated()->filtered);

                return $paginator;
            });
        }
    }
private function registerMacros()
    {
        if (
            method_exists(Relation::class, 'hasMacro') &&
            method_exists(Relation::class, 'macro') &&
            ! Relation::hasMacro('paginateFilter') &&
            ! Relation::hasMacro('simplePaginateFilter')
        ) {
            Relation::macro('paginateFilter', function () {
                $paginator = call_user_func_array([$this, 'paginate'], func_get_args());
                $paginator->appends($this->getRelated()->filtered);

                return $paginator;
            });
            Relation::macro('simplePaginateFilter', function () {
                $paginator = call_user_func_array([$this, 'simplePaginate'], func_get_args());
                $paginator->appends($this->getRelated()->filtered);

                return $paginator;
            });
        }
    }
private function registerMacros ( ) { if ( method_exists ( Relation :: class , 'hasMacro' ) && method_exists ( Relation :: class , 'macro' ) && ! Relation :: hasMacro ( 'paginateFilter' ) && ! Relation :: hasMacro ( 'simplePaginateFilter' ) ) { Relation :: macro ( 'paginateFilter' , function ( ) { $ paginator = call_user_func_array ( [ $ this , 'paginate' ] , func_get_args ( ) ) ; $ paginator -> appends ( $ this -> getRelated ( ) -> filtered ) ; return $ paginator ; } ) ; Relation :: macro ( 'simplePaginateFilter' , function ( ) { $ paginator = call_user_func_array ( [ $ this , 'simplePaginate' ] , func_get_args ( ) ) ; $ paginator -> appends ( $ this -> getRelated ( ) -> filtered ) ; return $ paginator ; } ) ; } }
Register paginate and simplePaginate macros on relations
BelongsToMany overrides the QueryBuilder's paginate to append the pivot.
Register paginate and simplePaginate macros on relations BelongsToMany overrides the QueryBuilder s paginate to append the pivot .