Completed
Push — master ( 545216...bb1888 )
by wen
14:38
created

Checkbox::getValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace Sco\Admin\Form\Elements;
4
5
use Illuminate\Support\Collection;
6
7
/**
8
 * Checkbox
9
 *
10
 * @see http://element.eleme.io/#/zh-CN/component/checkbox
11
 */
12
class Checkbox extends MultiSelect
13
{
14
    protected $type = 'checkbox';
15
16
    protected $defaultValue = [];
17
18
    protected $max;
19
    protected $min          = 0;
20
    protected $showCheckAll = false;
21
22
    public function getMax()
23
    {
24
        return $this->max;
25
    }
26
27
    public function setMax($value)
28
    {
29
        $this->max = (int)$value;
30
31
        $this->addValidationRule('max:' . $value);
32
33
        return $this;
34
    }
35
36
    public function getMin()
37
    {
38
        return $this->min;
39
    }
40
41
    public function setMin($value)
42
    {
43
        $this->min = (int)$value;
44
45
        $this->addValidationRule('min:' . $value);
46
47
        return $this;
48
    }
49
50
    public function isShowCheckAll()
51
    {
52
        return $this->showCheckAll;
53
    }
54
55
    public function enableShowCheckAll()
56
    {
57
        $this->showCheckAll = true;
58
59
        return $this;
60
    }
61
62
    public function toArray()
63
    {
64
        return parent::toArray() + [
65
                'min'          => $this->getMin(),
66
                'max'          => $this->getMax(),
67
                'showCheckAll' => $this->isShowCheckAll(),
68
            ];
69
    }
70
}
71