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

src/Form/Field/RadioButton.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
use Encore\Admin\Admin;
6
7 View Code Duplication
class RadioButton extends Radio
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $cascadeEvent = 'change';
13
14
    protected function addScript()
15
    {
16
        $script = <<<'SCRIPT'
17
$('.radio-group-toggle label').click(function() {
18
    $(this).parent().children().removeClass('active');
19
    $(this).addClass('active');
20
});
21
SCRIPT;
22
23
        Admin::script($script);
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function render()
30
    {
31
        $this->addScript();
32
33
        $this->addCascadeScript();
34
35
        $this->addVariables([
36
            'options' => $this->options,
37
            'checked' => $this->checked,
38
        ]);
39
40
        return parent::fieldRender();
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::fieldRender(); of type string|Illuminate\View\V...\Contracts\View\Factory adds the type Illuminate\Contracts\View\Factory to the return on line 40 which is incompatible with the return type declared by the interface Illuminate\Contracts\Support\Renderable::render of type string.
Loading history...
41
    }
42
}
43