浏览代码

详情中添加 filesize方法

咯拉咯啦 3 年之前
父节点
当前提交
95597b4e97
共有 1 个文件被更改,包括 17 次插入0 次删除
  1. 17 0
      src/Show/Field.php

+ 17 - 0
src/Show/Field.php

@@ -755,4 +755,21 @@ HTML;
     {
         return static::$extendedFields;
     }
+    
+    /**
+     * set file size
+     *
+     * @param  int  $dec
+     * @return Field
+     */
+    public function filesize($dec = 0)
+    {
+        return $this->unescape()->as(function ($value) use ($dec) {
+            if (empty($value)) {
+                return $this;
+            }
+
+            return format_byte($value, $dec);
+        });
+    }
 }