File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 88use Illuminate \Database \Eloquent \Relations \Relation ;
99use Illuminate \Http \Request ;
1010use Illuminate \Pagination \LengthAwarePaginator ;
11+ use Illuminate \Pagination \Paginator ;
1112use Illuminate \Support \Collection ;
1213use Illuminate \Support \Traits \ForwardsCalls ;
1314use Spatie \QueryBuilder \Concerns \AddsFieldsToQuery ;
@@ -124,18 +125,18 @@ public function __call($name, $arguments)
124125 $ this ->addAppendsToResults ($ result );
125126 }
126127
127- if ($ result instanceof LengthAwarePaginator) {
128+ if ($ result instanceof LengthAwarePaginator || $ result instanceof Paginator ) {
128129 $ this ->addAppendsToResults (collect ($ result ->items ()));
129130 }
130131
131132 return $ result ;
132133 }
133-
134+
134135 public function clone ()
135136 {
136137 return clone $ this ;
137138 }
138-
139+
139140 public function __clone ()
140141 {
141142 $ this ->subject = clone $ this ->subject ;
Original file line number Diff line number Diff line change 55use Illuminate \Database \Eloquent \Model ;
66use Illuminate \Http \Request ;
77use Illuminate \Pagination \LengthAwarePaginator ;
8+ use Illuminate \Pagination \Paginator ;
89use Illuminate \Support \Collection ;
910use Spatie \QueryBuilder \Exceptions \InvalidAppendQuery ;
1011use Spatie \QueryBuilder \QueryBuilder ;
@@ -159,4 +160,14 @@ protected function assertPaginateAttributeLoaded(LengthAwarePaginator $collectio
159160
160161 $ this ->assertFalse ($ hasModelWithoutAttributeLoaded , "The ` {$ attribute }` attribute was expected but not loaded. " );
161162 }
163+
164+ protected function assertSimplePaginateAttributeLoaded (Paginator $ collection , string $ attribute )
165+ {
166+ $ hasModelWithoutAttributeLoaded = $ collection
167+ ->contains (function (Model $ model ) use ($ attribute ) {
168+ return ! array_key_exists ($ attribute , $ model ->toArray ());
169+ });
170+
171+ $ this ->assertFalse ($ hasModelWithoutAttributeLoaded , "The ` {$ attribute }` attribute was expected but not loaded. " );
172+ }
162173}
You can’t perform that action at this time.
0 commit comments