Toggle appears to be always dirty

Hi, When setting up my observer (observing a boolean ìs_active) I noticed that the "Account is active"-email is always sended, even if the toggle hasn't been changed. When I just hit save without changing anything:
array:3 [▼ // app/Observers/UserObserver.php:29
"is_admin" => false
"is_active" => true
"updated_at" => "2023-07-05 10:47:22"
]
array:3 [▼ // app/Observers/UserObserver.php:29
"is_admin" => false
"is_active" => true
"updated_at" => "2023-07-05 10:47:22"
]
When I only change username:
array:4 [▼ // app/Observers/UserObserver.php:29
"firstname" => "Lila"
"is_admin" => false
"is_active" => true
"updated_at" => "2023-07-05 10:53:30"
]
array:4 [▼ // app/Observers/UserObserver.php:29
"firstname" => "Lila"
"is_admin" => false
"is_active" => true
"updated_at" => "2023-07-05 10:53:30"
]
Is this normal behaviour, and how can I fix this?
1 Reply
Stanneman
StannemanOP2y ago
Solved: Forgot to add a boolean cast to the model property 🙃
Want results from more Discord servers?
Add your server