Swiper.php
1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
 * Created by PhpStorm.
 * User: lishuai
 * Date: 2022/2/11
 * Time: 5:30 PM
 */
namespace App\Admin\Extensions;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid\Displayers\AbstractDisplayer;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Facades\Storage;
class Swiper extends AbstractDisplayer
{
    public function display($server = '', $width = 200, $height = 200)
    {
        // todo
//        if ($this->value instanceof Arrayable) {
//            $this->value = $this->value->toArray();
//        }
//
//        return collect((array) $this->value)->filter()->map(function ($path) use ($server, $width, $height) {
//            if (url()->isValidUrl($path) || mb_strpos($path, 'data:image') === 0) {
//                $src = $path;
//            } elseif ($server) {
//                $src = rtrim($server, '/').'/'.ltrim($path, '/');
//            } else {
//                $src = Storage::disk(config('admin.upload.disk'))->url($path);
//            }
//
//            return "<img data-action='preview-img' src='$src' style='max-width:{$width}px;max-height:{$height}px;cursor:pointer' class='img img-thumbnail' />";
//        })->implode(' ');
    }
}