Browse Source

Column::downloadable增加$disk参数

jqh 6 năm trước cách đây
mục cha
commit
27ee779407
2 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 1 1
      src/Grid/Column.php
  2. 3 3
      src/Grid/Displayers/Downloadable.php

+ 1 - 1
src/Grid/Column.php

@@ -32,7 +32,7 @@ use Illuminate\Support\Str;
  * @method $this modal($title = '', \Closure $callback = null)
  * @method $this tree($callbackOrNodes = null)
  * @method $this qrcode($formatter = null, $width = 150, $height = 150)
- * @method $this downloadable()
+ * @method $this downloadable($server = '', $disk = null)
  * @method $this copyable()
  *
  * @method $this limit($limit = 100, $end = '...')

+ 3 - 3
src/Grid/Displayers/Downloadable.php

@@ -7,9 +7,9 @@ use Illuminate\Support\Facades\Storage;
 
 class Downloadable extends AbstractDisplayer
 {
-    public function display($server = '')
+    public function display($server = '', $disk = null)
     {
-        return collect(Helper::array($this->value))->filter()->map(function ($value) use ($server) {
+        return collect(Helper::array($this->value))->filter()->map(function ($value) use ($server, $disk) {
             if (empty($value)) {
                 return '';
             }
@@ -19,7 +19,7 @@ class Downloadable extends AbstractDisplayer
             } elseif ($server) {
                 $src = rtrim($server, '/') . '/' . ltrim($value, '/');
             } else {
-                $src = Storage::disk(config('admin.upload.disk'))->url($value);
+                $src = Storage::disk($disk ?: config('admin.upload.disk'))->url($value);
             }
 
             $name = basename($value);