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

AlexandreRS's avatar

Problems whith money field with comma

Hello there! I'm brazilian, so my form has a field money type BR, and a I use comma. When I submit my form, I use str_replace('.', ',', $preco) but still I have problem to persist it in mysql whith Model::create($request->all()); . I use this way because I need take the ID saved. There are someone to help me?

0 likes
2 replies
Talinon's avatar

You can modify the data in the request object before calling $request->all()

$request->merge(['preco' => str_replace('.', ',', $request->preco)]);
Model::create($request->all());

Please or to participate in this conversation.