Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bricxrain's avatar

Renaming object keys name in PHP Laravel Request

I have a JSON request and i need to change all object key names similar on my model object keys, i'm having a difficulty about nested array objects, and also dot notation is not working on this part.

Here is my code on my validation request:

0 likes
1 reply
rgillera's avatar

You can implement an interface to all your models that will map every json request to your model attributes. Then type hint that interface in your controllers method

Hope this helps

Please or to participate in this conversation.