Issues (368)

src/Admin/Form/BulkEditFormBuilder.php (2 issues)

1
<?php
2
3
namespace Arbory\Base\Admin\Form;
4
5
use Arbory\Base\Html\Html;
6
use Arbory\Base\Admin\Widgets\Button;
7
use Arbory\Base\Html\Elements\Content;
8
use Arbory\Base\Html\Elements\Element;
9
10
/**
11
 * Class BulkEditFormBuilder.
12
 */
13
class BulkEditFormBuilder extends Builder
14
{
15
    /**
16
     * @param $route
17
     * @param  array  $parameters
18
     * @return string
19
     */
20
    public function url($route, $parameters = [])
21
    {
22
        return $this->form->getModule()->url($route, $parameters);
23
    }
24
25
    /**
26
     * @return Element
27
     */
28
    protected function header()
29
    {
30
        return Html::header([
31
            Html::h1($this->form->getTitle()),
32
        ]);
33
    }
34
35
    /**
36
     * @return Element
37
     */
38
    protected function form()
39
    {
40
        $form = Html::form()->addAttributes([
41
            'id' => 'edit-resources',
42
            'class' => 'edit-resources',
43
            'novalidate' => 'novalidate',
44
            'enctype' => 'multipart/form-data',
45
            'accept-charset' => 'UTF-8',
46
            'method' => 'post',
47
            'action' => $this->form->getAction(),
48
            'data-remote' => 'true',
49
            'data-remote-validation' => 'true',
50
            'data-type' => 'json',
51
        ]);
52
53
        $form->append(csrf_field());
54
55
        $form->append(Html::input()->setName('_method')->setType('hidden')->setValue('POST'));
56
57
        return $form;
58
    }
59
60
    /**
61
     * @return Element
62
     */
63
    protected function footer()
64
    {
65
        $primary = Html::div()->addClass('primary');
66
67
        $primary->append(
68
            Html::link()
69
                ->addClass('button secondary with-icon')
70
                ->addAttributes(['data-type' => 'cancel'])
71
                ->append(Html::i('not_interested')->addClass('mt-icon'))
72
                ->append(trans('arbory::resources.cancel'))
73
        );
74
75
        $primary->append(
76
            Button::create('save', true)
0 ignored issues
show
true of type true is incompatible with the type null|string expected by parameter $value of Arbory\Base\Admin\Widgets\Button::create(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

76
            Button::create('save', /** @scrutinizer ignore-type */ true)
Loading history...
77
                ->type('submit', 'primary')
78
                ->withIcon('check')
79
                ->disableOnSubmit()
80
                ->title(trans('arbory::resources.save'))
81
        );
82
83
        $footerTools = Html::div([
84
            $primary,
85
        ])->addClass('tools');
86
87
        return Html::footer($footerTools);
88
    }
89
90
    /**
91
     * @return Content|Element
92
     */
93
    public function render()
94
    {
95
        $content = Html::div()->addClass('body');
96
97
        $content->append($this->form->fields()->render());
98
99
        return new Content([
0 ignored issues
show
array(Arbory\Base\Html\H...pend($this->footer()))) of type array<integer,Arbory\Base\Html\Elements\Element> is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $items of Arbory\Base\Html\Elements\Content::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

99
        return new Content(/** @scrutinizer ignore-type */ [
Loading history...
100
            Html::section(
101
                $this->form()
102
                    ->append($this->header())
103
                    ->append($content)
104
                    ->append($this->footer())
105
            ),
106
        ]);
107
    }
108
}
109