api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.42k stars 863 forks source link

fix(laravel): visible and hidden fields support #6538

Closed dunglas closed 1 month ago

dunglas commented 1 month ago
Q A
Branch? main
Tickets n/a
License MIT
Doc PR n/a

Model::$visible is an allow list. If it is defined, only fields explicitly listed in the array must be visible. This patch fixes the issue and adds some tests for the feature.

According to the docs, it's also possible to hide the field for an instance by using makeVisible() and makeHidden(). I may be wrong, but this feature doesn't seem to be currently supported. This should be fixed in a follow-up PR.