Skip to content
Advertisement

How to update data in Laravel controller?

I am trying to update my template details in the controller. But currently, my code is not working. It is not updating the fields. Anyhow if I add $template->save(). It saves the updated record as a new record. How to make my current code work? Why I am facing this situation? Please, someone, explain to me and correct my code as still, I am learning Laravel. Thanks in advance.

update function in TemplateController

JavaScript

Advertisement

Answer

you creating new object $template=new Template(); but you need to update existing one so try below code

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement