Browse Source

详情中添加 filesize方法

咯拉咯啦 3 years ago
parent
commit
95597b4e97
1 changed files with 17 additions and 0 deletions
  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);
+        });
+    }
 }