Can't access attributes of stdClass in afterQuery method using pagination #54112
Replies: 2 comments
-
@filipegomessouza
Or You can use this->
through or tap are alternative approach. Both methods modify the collection after pagination and Maintains pagination Metadata |
Beta Was this translation helpful? Give feedback.
-
@MrVH-IR The Eloquent Builder works normally with pagination. For example:
The above code works... The question that remains is why the eloquent builder works, but the query builder doesn't? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Laravel Version
11.3.0
PHP Version
8.3.13
Database Driver & Version
No response
Description
I trying to use afterQuery method with Query Builder, but if pagination is used, some problems are happening.
Steps To Reproduce
Consider the given code:
The following error is obtained: Undefined property: stdClass::$name
But if i use ->get() instead ->paginate() method, it works.
Do someone know what is the problem with my code?
Beta Was this translation helpful? Give feedback.
All reactions