Replies: 2 comments 1 reply
-
You want to do this: #[TypeScript]
#[MapOutputName(CamelCaseMapper::class)]
class UpdateOrderData extends Data
{
public function __construct(
public Optional|TransportTrailerType $trailer_type,
) {
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
When doing as such, the generated TypeScript looks fine. {
"trailerType": "test"
} Ray returns the following data Modules\Transport\Requests\UpdateOrderData {#2105} So the data is not mapped correctly. Of course we can solve this by using the MapInputName or MapName but we end up with CamelCase in the backend. Losing the ability to quickly update the entity $order->update($updateOrderData->toArray()); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
In our team the front-end guys like to work with CamelCasing, while the Laravel back-end makes use of snake_casing.
Currently we are using the laravel-data package and typescript transformer to create a seamless flow between each other.
In order to to create the correct typescript for the front-end team we opted to use CamelCasing for our DTO's and use the output mapper so we have the snake_casing when using the to_array() function so we can easily generate model from it.
But the DataTypeScriptTransformer uses the
outputMappedName
for the property name after transforming. Causing a snake_casing property in the TypeScript as well.Turning things around isn't an option either.
because this will end up as snake_casing in the typescript as well.
Solution
I feel like there can be a need for a config parameter to make the use of the mapped name optional.
If this is within the vision of the package I can create a PR for this.
Beta Was this translation helpful? Give feedback.
All reactions