-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Model::preventAccessingMissingAttributes()" Causes Exception During Pagination with ResourceCollection #52214
Comments
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
Hmm, in a route:
Then UserResource looks like:
Does that work? Trying to narrow down what the issue is! |
@lrljoe this will work the problem is not with the the cause of the problem is in this line
but i don't have the experience to understand how to fix it |
I tried to fix it. It will fix the problem. I don't really know if the scope of the test is ok. But the problem would be fixed with referenced PR |
@Katalam I think u are using php artisan make:resource UserCollection
return new UserCollection(User::paginate()); |
I did. to fix the problem, but not to write the test |
Laravel Version
11.16.0
PHP Version
8.3.9
Database Driver & Version
MariaDB 11.4.2
Description
When using pagination with
ResourceCollection
whileModel::preventAccessingMissingAttributes()
is activated, an attempt to accessresource
attributes occurs. This access results in a violation of the prevent access to missing attributes policy, causing an exception to be thrown.Steps To Reproduce
php artisan db:seed
AppServiceProvider
add in the register method thisModel::shouldBeStrict();
or thisModel::preventAccessingMissingAttributes();
php artisan make:resource UserCollection
return new UserCollection(User::paginate());
The text was updated successfully, but these errors were encountered: