Accessors and Mutators – A Weblog of Priyank Maniar https://priyank.rocks Articles on web development & mobile app development Sat, 12 Jun 2021 20:42:04 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 Problem with Laravel Accessors and Mutators https://priyank.rocks/problem-with-laravel-accessors-and-mutators/ Sat, 12 Jun 2021 18:16:26 +0000 https://priyank.rocks/?p=7859 update() does not trigger mutators. There is a workaround to it that does work. Problem 2: For the ->sum() the getters/accessors do not...]]> 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.

]]>