We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Deleting hasOne Relationship creates new row in database

Hello!

I have a hasOne relationship within a model entitles User that relates to the Permissions model. Any time I delete the relationship, a new row is created in the Permissions table with the previous permissions information, and is unrealted to the current User object.

This created a problem with the response body as well, and forced me to return a findFirst rather than the calucalted object in the controller. Has anoyone come across this or know of a solution?

In beforeUpdate()

$this->userPermissions->delete()

updateUserAction Controller

return User::findFirstById($user->id)

Could you share the User model code?