OwenIt\Auditing\Auditable::cleanHiddenAuditAttributes PHP Method

cleanHiddenAuditAttributes() public method

Remove the value of attributes which are hidden or not visible on the model.
public cleanHiddenAuditAttributes ( array $attributes ) : array
$attributes array
return array
    public function cleanHiddenAuditAttributes(array $attributes)
    {
        if ($this->isAuditRespectsHidden()) {
            // Get hidden and visible attributes from the model
            $hidden = $this->getHidden();
            $visible = $this->getVisible();
            // If visible is set, set to null any attributes which are not in visible
            if (count($visible) > 0) {
                foreach ($attributes as $attribute => &$value) {
                    if (!in_array($attribute, $visible)) {
                        $value = null;
                    }
                }
            }
            unset($value);
            // If hidden is set, set to null any attributes which are in hidden
            if (count($hidden) > 0) {
                foreach ($hidden as $attribute) {
                    if (array_key_exists($attribute, $attributes)) {
                        $attributes[$attribute] = null;
                    }
                }
            }
        }
        return $attributes;
    }