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
…but that defeats the elegance of the DTO, especially if the model has many fields.
I also experimented with SnakeCaseMapper in #[MapInputName] and #[MapOutputName], but none of those gave me the result I expected either.
Is there a recommended way to handle this? Ideally, I’d like to keep using camelCase on the frontend and in TypeScript, but snake_case in the DB without this extra mapping.
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I have the following
Data
class:In my controller I have:
Here,
$data->all()
gives me camelCase keys likecarId
, which don’t match the snake_case column names in the database. So this fails.The only workaround I see is manually mapping everything:
…but that defeats the elegance of the DTO, especially if the model has many fields.
I also experimented with
SnakeCaseMapper
in#[MapInputName]
and#[MapOutputName]
, but none of those gave me the result I expected either.Is there a recommended way to handle this? Ideally, I’d like to keep using camelCase on the frontend and in TypeScript, but snake_case in the DB without this extra mapping.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions