Bypass accessor when using increment() or decrement() methods #52694
-
Hi Everyone, I noticed that incrementing/decrementing a database column with It seems to me that accessors should never be executed when incrementing/decrementing a column, but maybe I'm missing a use case? Curious your thoughts. I believe this is where the accessor is being fired: framework/src/Illuminate/Database/Eloquent/Model.php Lines 977 to 979 in b7c6287 PR submitted: #52701 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 20 replies
-
$this->{$column} is generating that. as it is a 'get/read'. |
Beta Was this translation helpful? Give feedback.
-
Why not? Can you elaborate? If someone has an accessor to a JSON field stored in DB, then reading from the accessor would be mandatory. |
Beta Was this translation helpful? Give feedback.
If you want to use a pure database approach, you can use the underlying
Illuminate\Database\Query\Builder@increment()
method instead:framework/src/Illuminate/Database/Query/Builder.php
Lines 3924 to 3931 in a2c66ad