Cast array fields to JSON when saving in upsert model #900
Unanswered
mauriciodinamarca
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
-
Hello!
We used spatie/data-transfer-object package before, and we had an easy way to transform array properties to JSON with a transformer (or caster I think), but with spatie-data I couldn't find a better way to cast to JSON before saving. As an example, here's a Data object using Microsoft graph api (omitted all parameters for brevity):
We make a call using another package (saloon) and it returns the laravel-data DTO object. Before saving with upsert, I need to transform the fields to json, something like this:
Is there a better way when transforming to array those fields get transformed to JSON?
I couldn't find (read this and also looked in Github discussions)
Thanks in advance!
Best,
Beta Was this translation helpful? Give feedback.
All reactions