Completed
Push — master ( a6d5b0...1121c7 )
by wen
12:56
created

Image::setDisk()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
4
namespace Sco\Admin\View\Columns;
5
6
use Sco\Admin\Traits\StorageTrait;
7
8
class Image extends Column
9
{
10
    use StorageTrait;
11
12
    protected $template = '<img v-viewer="column.options" :width="value.width" :src="value.image" v-if="value.image">';
13
14
    /**
15
     * @var string
16
     */
17
    protected $imageWidth = '80px';
18
19
    /**
20
     * @return string
21
     */
22
    public function getImageWidth()
23
    {
24
        return $this->imageWidth;
25
    }
26
27
    /**
28
     * @param string $width
29
     *
30
     * @return $this
31
     */
32
    public function setImageWidth($width)
33
    {
34
        $this->imageWidth = $width;
35
36
        return $this;
37
    }
38
39
    public function getValue()
40
    {
41
        $value = parent::getValue();
42
        if (!empty($value) && (strpos($value, '://') === false)) {
43
            $value = $this->getFileUrl($value);
44
        }
45
46
        return [
47
            'image' => $value,
48
            'width' => $this->getImageWidth(),
49
        ];
50
    }
51
52
    public function toArray()
53
    {
54
        return parent::toArray() + [
55
                'options' => [
56
                    'toolbar' => false,
57
                    'navbar'  => false,
58
                ],
59
            ];
60
    }
61
}
62