diff --git a/src/Venturecraft/Revisionable/FieldFormatter.php b/src/Venturecraft/Revisionable/FieldFormatter.php index b9572c34..3cf89d88 100644 --- a/src/Venturecraft/Revisionable/FieldFormatter.php +++ b/src/Venturecraft/Revisionable/FieldFormatter.php @@ -117,4 +117,29 @@ public static function datetime($value, $format = 'Y-m-d H:i:s') return $datetime->format($format); } + + /** + * Format options + * + * @param string $value + * @param string $format + * @return string + */ + public static function options($value, $format) + { + $options = explode('|', $format); + + $result = []; + + foreach ($options as $option) { + $transform = explode('.', $option); + $result[$transform[0]] = $transform[1]; + } + + if (isset($result[$value])) { + return $result[$value]; + } + + return 'undefined'; + } }