Completed
Pull Request — master (#1893)
by
unknown
03:04
created

Number::min()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
5
class Number extends Text
6
{
7
    protected static $js = [
8
        '/vendor/laravel-admin/number-input/bootstrap-number-input.js',
9
    ];
10
11
    public function render()
12
    {
13
        $this->default((int) $this->default);
14
15
        $this->script = <<<EOT
16
17
$('{$this->getElementClassSelector()}:not(.initialized)')
18
    .addClass('initialized')
19
    .bootstrapNumber({
20
        upClass: 'success',
21
        downClass: 'primary',
22
        center: true
23
    });
24
25
EOT;
26
27
        $this->prepend('')->defaultAttribute('style', 'width: 100px');
28
29
        return parent::render();
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::render(); of type Illuminate\Contracts\Vie...ry|Illuminate\View\View adds the type Illuminate\Contracts\View\Factory to the return on line 29 which is incompatible with the return type declared by the interface Illuminate\Contracts\Support\Renderable::render of type string.
Loading history...
30
    }
31
32
    /**
33
     * Set min value of number field.
34
     *
35
     * @param integer $value
36
     * @return $this
37
     */
38
    public function min($value)
39
    {
40
        $this->attribute('min', $value);
41
42
        return $this;
43
    }
44
45
    /**
46
     * Set max value of number field.
47
     *
48
     * @param integer $value
49
     * @return $this
50
     */
51
    public function max($value)
52
    {
53
        $this->attribute('max', $value);
54
55
        return $this;
56
    }
57
}
58