Skip to main content
LaravelAccessors and Mutators

Problem with Laravel Accessors and Mutators

By June 12, 2021No Comments

Problem 1:

->update() does not trigger mutators. There is a workaround to it that does work.

Problem 2:

For the ->sum() the getters/accessors do not work.

1
PaymentMade::whereUserId($userId)->sum('amount')

The above trick does not help either. At that moment, I felt I don’t know how many problems we are going to run into. With as much less time we developers have, it felt wise to not use it.