You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all I would like to thank you for the great work you are doing, your packages rock 😃
I have an idea which I might be useful when selecting fields, there are cases when you need to specify immutable default select fields for your model or include relationships. Say that you have specific attributes that are not present in the DB of your model but are computed on spot casts or accessors, when in this situation a laravel resource would provide untruthful output on that attribute because the fields were not selected to begin with. A practical example of such case would be timestamps sent_at, declined_at, approved_at which in a model you would append a Enum of status.
Now to tackle this issue i believe it would be nice to have a ->defaultSelect(...) method that would by default provide the given select fields. This would also have the bonus side effect of limiting a heavy responses in KB size when you combine it with a laravel resource file when attributes have$this->whenNotNull(...).
I'd be glad to know what you think about this idea. I could also help with a fork if you would be interested 🙂
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
First of all I would like to thank you for the great work you are doing, your packages rock 😃
I have an idea which I might be useful when selecting fields, there are cases when you need to specify immutable default select fields for your model or
include
relationships. Say that you have specific attributes that are not present in the DB of your model but are computed on spotcasts or accessors
, when in this situation a laravelresource
would provide untruthful output on that attribute because the fields were not selected to begin with. A practical example of such case would be timestampssent_at
,declined_at
,approved_at
which in a model you would append a Enum of status.Now to tackle this issue i believe it would be nice to have a
->defaultSelect(...)
method that would by default provide the given select fields. This would also have the bonus side effect of limiting a heavy responses in KB size when you combine it with a laravel resource file when attributes have$this->whenNotNull(...)
.I'd be glad to know what you think about this idea. I could also help with a fork if you would be interested 🙂
Beta Was this translation helpful? Give feedback.
All reactions