Skip to content
Advertisement

Laravel eloquent mutators not work on update data

I have in my model accessors and mutators for hash/rehash data in database table fields. For example:

JavaScript

When I’ll save data to database all sending datas saving in hashed form but on update data not hashed. My save/update code:

JavaScript

When I first time save this info to db:

enter image description here

When I second time enter to current URL data will be updated:

enter image description here Why does not the information be stored in an encrypted form when updating information?

Advertisement

Answer

Your problem is in this line:

JavaScript

Mutators and accessors work on eloquent and not on Query Builders. You are using update function which is a query builder function, so you are updating your database directly. Use this:

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