DojoPhaseController::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Admin\Controllers;
4
5
use App\Models\Eloquent\Dojo\Dojo;
6
use App\Http\Controllers\Controller;
7
use App\Models\Eloquent\Dojo\DojoPhase;
8
use Encore\Admin\Controllers\HasResourceActions;
9
use Encore\Admin\Form;
10
use Encore\Admin\Grid;
11
use Encore\Admin\Layout\Content;
12
use Encore\Admin\Show;
13
14
class DojoPhaseController extends Controller
15
{
16
    use HasResourceActions;
17
18
    /**
19
     * Index interface.
20
     *
21
     * @param Content $content
22
     * @return Content
23
     */
24
    public function index(Content $content)
25
    {
26
        return $content
27
            ->header(__('admin.dojophases.index.header'))
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.index.header') can also be of type array and array; however, parameter $header of Encore\Admin\Layout\Content::header() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

27
            ->header(/** @scrutinizer ignore-type */ __('admin.dojophases.index.header'))
Loading history...
28
            ->description(__('admin.dojophases.index.description'))
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.index.description') can also be of type array and array; however, parameter $description of Encore\Admin\Layout\Content::description() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

28
            ->description(/** @scrutinizer ignore-type */ __('admin.dojophases.index.description'))
Loading history...
29
            ->body($this->grid()->render());
30
    }
31
32
    /**
33
     * Show interface.
34
     *
35
     * @param mixed $id
36
     * @param Content $content
37
     * @return Content
38
     */
39
    public function show($id, Content $content)
40
    {
41
        return $content
42
            ->header(__('admin.dojophases.show.header'))
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.show.header') can also be of type array and array; however, parameter $header of Encore\Admin\Layout\Content::header() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

42
            ->header(/** @scrutinizer ignore-type */ __('admin.dojophases.show.header'))
Loading history...
43
            ->description(__('admin.dojophases.show.description'))
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.show.description') can also be of type array and array; however, parameter $description of Encore\Admin\Layout\Content::description() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

43
            ->description(/** @scrutinizer ignore-type */ __('admin.dojophases.show.description'))
Loading history...
44
            ->body($this->detail($id));
45
    }
46
47
    /**
48
     * Edit interface.
49
     *
50
     * @param mixed $id
51
     * @param Content $content
52
     * @return Content
53
     */
54
    public function edit($id, Content $content)
55
    {
56
        return $content
57
            ->header(__('admin.dojophases.edit.header'))
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.edit.header') can also be of type array and array; however, parameter $header of Encore\Admin\Layout\Content::header() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

57
            ->header(/** @scrutinizer ignore-type */ __('admin.dojophases.edit.header'))
Loading history...
58
            ->description(__('admin.dojophases.edit.description'))
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.edit.description') can also be of type array and array; however, parameter $description of Encore\Admin\Layout\Content::description() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

58
            ->description(/** @scrutinizer ignore-type */ __('admin.dojophases.edit.description'))
Loading history...
59
            ->body($this->form()->edit($id));
60
    }
61
62
    /**
63
     * Create interface.
64
     *
65
     * @param Content $content
66
     * @return Content
67
     */
68
    public function create(Content $content)
69
    {
70
        return $content
71
            ->header(__('admin.dojophases.create.header'))
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.create.header') can also be of type array and array; however, parameter $header of Encore\Admin\Layout\Content::header() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

71
            ->header(/** @scrutinizer ignore-type */ __('admin.dojophases.create.header'))
Loading history...
72
            ->description(__('admin.dojophases.create.description'))
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.create.description') can also be of type array and array; however, parameter $description of Encore\Admin\Layout\Content::description() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

72
            ->description(/** @scrutinizer ignore-type */ __('admin.dojophases.create.description'))
Loading history...
73
            ->body($this->form());
74
    }
75
76
    /**
77
     * Make a grid builder.
78
     *
79
     * @return Grid
80
     */
81
    protected function grid()
82
    {
83
        $grid=new Grid(new DojoPhase);
84
        $grid->column('id', "ID")->sortable();
85
        $grid->column("name", __('admin.dojophases.name'))->editable();
0 ignored issues
show
Bug introduced by
It seems like __('admin.dojophases.name') can also be of type array and array; however, parameter $label of Encore\Admin\Grid::column() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

85
        $grid->column("name", /** @scrutinizer ignore-type */ __('admin.dojophases.name'))->editable();
Loading history...
86
87
        $grid->column("passline", __('admin.dojophases.passline'));
88
        $grid->column("order", __('admin.dojophases.order'))->sortable();
89
        $grid->created_at(__('admin.created_at'));
90
        $grid->updated_at(__('admin.updated_at'));
91
92
        $grid->filter(function(Grid\Filter $filter) {
93
            $filter->column(6, function($filter) {
94
                $filter->like('name', __('admin.dojophases.name'));
95
            });
96
        });
97
        return $grid;
98
    }
99
100
    /**
101
     * Make a show builder.
102
     *
103
     * @param mixed $id
104
     * @return Show
105
     */
106
    protected function detail($id)
107
    {
108
        $show=new Show(DojoPhase::findOrFail($id));
109
        $show->id('ID');
110
        $show->name(__('admin.dojophases.name'));
111
        $show->description(__('admin.dojophases.description'));
112
        $show->passline(__('admin.dojophases.passline'));
113
        $show->order(__('admin.dojophases.order'));
114
        return $show;
115
    }
116
117
    /**
118
     * Make a form builder.
119
     *
120
     * @return Form
121
     */
122
    protected function form()
123
    {
124
        $form=new Form(new DojoPhase);
125
        $form->tab('Basic', function(Form $form) {
126
            $form->display('id', 'ID');
127
            $form->text('name', __('admin.dojophases.name'))->rules('required');
128
            $form->textarea('description', __('admin.dojophases.description'))->rules('required');
129
            $form->number('passline', __('admin.dojophases.passline'))->default(0)->rules('required');
130
            $form->number('order', __('admin.dojophases.order'))->default(0)->rules('required');
131
        });
132
        return $form;
133
    }
134
}
135