Skip to content

A free open source IT asset/license management system

Created mutator on category checkin_email

snipe83ee07cca122
diff --git a/app/Models/Category.php b/app/Models/Category.php
index c06ac38543..06d338a1c4 100755
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -247,6 +247,26 @@ class Category extends SnipeModel
}
}
+ /**
+ * -----------------------------------------------
+ * BEGIN MUTATORS
+ * -----------------------------------------------
+ **/
+
+ /**
+ * This sets the checkin_value to a boolean 0 or 1. This accounts for forms or API calls that
+ * explicitly pass the checkin_email field but it has a null or empty value.
+ *
+ * This will also correctly parse "true"/"false" passed.
+ *
+ * @param $value
+ * @return void
+ */
+ public function setCheckinEmailAttribute($value)
+ {
+ $this->attributes['checkin_email'] = (int) filter_var($value, FILTER_VALIDATE_BOOLEAN);
+ }
+
/**
* -----------------------------------------------
* BEGIN QUERY SCOPES