rexlabsio / smokescreen-laravel-php

Library for integrating the Smokescreen transformation library with the Laravel framework
MIT License
4 stars 1 forks source link

Consider model casts when generating transformers #15

Closed cerbero90 closed 6 years ago

cerbero90 commented 6 years ago

@lachlankrautz correctly pointed out we should also consider the $casts property to determine the properties type of models when we generate transformers from CLI.

jodiedunlop commented 6 years ago

Hey, just clarifying this one:

Do you mean with regards to declaring their format in the transformer?

If you have casts on the model, and do not declare format in the transformer then it would be automatically using the casted value that eloquent returns when you access a property... in which case declaring it in the transformer might essentially mean it is being cast/formatted twice.

lachlankrautz commented 6 years ago

Yeah sounds fine, I was thinking your were casting based on the schema which might not match. You'd probably want to just leave it if there is a cast entry.

On Tue, Jul 3, 2018 at 5:08 PM, Jodie notifications@github.com wrote:

Hey, just clarifying this one:

Do you mean with regards to declaring their format in the transformer?

If you have casts on the model, and do not declare format in the transformer then it would be automatically using the casted value that eloquent returns when you access a property... in which case declaring it in the transformer might essentially mean it is being cast/formatted twice.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rexlabsio/smokescreen-laravel-php/issues/15#issuecomment-402035505, or mute the thread https://github.com/notifications/unsubscribe-auth/AAnUMmPdNIejZbcMR3cwDNQfmUqViSF3ks5uCxhygaJpZM4UqTPg .