Why is the $request
argument in JsonResource->toArray()
required if it is never used?
#54616
Unanswered
audreyteles
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone, today I came across a question:
The
JsonResource
methodtoArray
has a required argument$request
, but this variable isn’t used anywhere. So, it looks like an optional argument to me, not a required one... Because if you only need to transform your data from a model, you still have to pass a request to the method, even though it will never be used.Does anyone here know why it is a required argument?
Below is a discussion that has already been opened and touches on a similar topic to my question, but in another category:
#54395
Beta Was this translation helpful? Give feedback.
All reactions