summaryrefslogtreecommitdiff
path: root/app/Model/Base.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Model/Base.php')
-rw-r--r--app/Model/Base.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/Model/Base.php b/app/Model/Base.php
index 973462cc..e700f326 100644
--- a/app/Model/Base.php
+++ b/app/Model/Base.php
@@ -62,14 +62,30 @@ abstract class Base extends \Core\Base
public function removeFields(array &$values, array $keys)
{
foreach ($keys as $key) {
- if (isset($values[$key])) {
+ if (array_key_exists($key, $values)) {
+ unset($values[$key]);
+ }
+ }
+ }
+
+ /**
+ * Remove keys from an array if empty
+ *
+ * @access public
+ * @param array $values Input array
+ * @param string[] $keys List of keys to remove
+ */
+ public function removeEmptyFields(array &$values, array $keys)
+ {
+ foreach ($keys as $key) {
+ if (array_key_exists($key, $values) && empty($values[$key])) {
unset($values[$key]);
}
}
}
/**
- * Force some fields to be at 0 if empty
+ * Force fields to be at 0 if empty
*
* @access public
* @param array $values Input array