Completed
Push — master ( 82be35...1537c0 )
by Song
02:28
created

src/Form/Field/Color.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
5
class Color extends Text
6
{
7
    protected static $css = [
8
        '/vendor/laravel-admin/AdminLTE/plugins/colorpicker/bootstrap-colorpicker.min.css',
9
    ];
10
11
    protected static $js = [
12
        '/vendor/laravel-admin/AdminLTE/plugins/colorpicker/bootstrap-colorpicker.min.js',
13
    ];
14
15
    /**
16
     * Use `hex` format.
17
     *
18
     * @return $this
19
     */
20
    public function hex()
21
    {
22
        return $this->options(['format' => 'hex']);
23
    }
24
25
    /**
26
     * Use `rgb` format.
27
     *
28
     * @return $this
29
     */
30
    public function rgb()
31
    {
32
        return $this->options(['format' => 'rgb']);
33
    }
34
35
    /**
36
     * Use `rgba` format.
37
     *
38
     * @return $this
39
     */
40
    public function rgba()
41
    {
42
        return $this->options(['format' => 'rgba']);
43
    }
44
45
    /**
46
     * Render this filed.
47
     *
48
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
49
     */
50 View Code Duplication
    public function render()
51
    {
52
        $options = json_encode($this->options);
53
54
        $this->script = "$('{$this->getElementClassSelector()}').parent().colorpicker($options);";
55
56
        $this->prepend('<i></i>')
57
            ->defaultAttribute('style', 'width: 140px');
58
59
        return parent::render();
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::render(); of type string|Illuminate\View\V...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 59 which is incompatible with the return type declared by the interface Illuminate\Contracts\Support\Renderable::render of type string.
Loading history...
60
    }
61
}
62