Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#60)
by Agus
01:14
created

MenuCrudController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 7
dl 0
loc 107
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 6 1
A setupListOperation() 0 10 1
A setupShowOperation() 0 5 1
A setupCreateOperation() 0 12 1
A setupUpdateOperation() 0 4 1
A setupColumns() 0 16 1
A setupFields() 0 16 1
1
<?php
2
3
namespace Backpack\CRUD\app\Http\Controllers\Admin;
4
5
use Backpack\CRUD\app\Http\Controllers\CrudController;
6
use Backpack\CRUD\app\Http\Requests\MenuRequest;
7
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
8
9
/**
10
 * Class MenuCrudController.
11
 * @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
12
 */
13
class MenuCrudController extends CrudController
14
{
15
    use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
16
    use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
17
    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
18
    use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
19
    use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
20
21
    /**
22
     * Configure the CrudPanel object. Apply settings to all operations.
23
     *
24
     * @return void
25
     */
26
    public function setup()
27
    {
28
        $this->crud->setModel(\Backpack\CRUD\app\Models\Menu::class);
29
        $this->crud->setRoute(config('backpack.base.route_prefix').'/menu');
30
        $this->crud->setEntityNameStrings('menu', 'menus');
31
    }
32
33
    /**
34
     * Define what happens when the List operation is loaded.
35
     *
36
     * @see  https://backpackforlaravel.com/docs/crud-operation-list-entries
37
     * @return void
38
     */
39
    protected function setupListOperation()
40
    {
41
        $this->setupColumns(false);
42
43
        /**
44
         * Columns can be defined using the fluent syntax or array syntax:
45
         * - $this->crud->column('price')->type('number');
46
         * - $this->crud->addColumn(['name' => 'price', 'type' => 'number']);.
47
         */
48
    }
49
50
    protected function setupShowOperation()
51
    {
52
        $this->crud->set('show.setFromDb', false);
53
        $this->setupColumns(true);
54
    }
55
56
    /**
57
     * Define what happens when the Create operation is loaded.
58
     *
59
     * @see https://backpackforlaravel.com/docs/crud-operation-create
60
     * @return void
61
     */
62
    protected function setupCreateOperation()
63
    {
64
        $this->crud->setValidation(MenuRequest::class);
65
66
        $this->setupFields();
67
68
        /**
69
         * Fields can be defined using the fluent syntax or array syntax:
70
         * - $this->crud->field('price')->type('number');
71
         * - $this->crud->addField(['name' => 'price', 'type' => 'number']));.
72
         */
73
    }
74
75
    /**
76
     * Define what happens when the Update operation is loaded.
77
     *
78
     * @see https://backpackforlaravel.com/docs/crud-operation-update
79
     * @return void
80
     */
81
    protected function setupUpdateOperation()
82
    {
83
        $this->setupCreateOperation();
84
    }
85
86
    private function setupColumns($isShowing = false)
0 ignored issues
show
Unused Code introduced by
The parameter $isShowing is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
87
    {
88
        $this->crud->addButtonFromModelFunction('line', 'custom_actions', 'customActions', 'beginning');
0 ignored issues
show
Documentation introduced by
'beginning' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
89
90
        $this->crud->addColumn([
91
            'name'  => 'name',
92
            'label' => 'Name',
93
            'type'  => 'text',
94
        ]);
95
        $this->crud->addColumn([
96
            'name'    => 'placement',
97
            'label'   => 'Placement',
98
            'type'    => 'select_from_array',
99
            'options' => config('backpack.menu.placement'),
100
        ]);
101
    }
102
103
    private function setupFields()
104
    {
105
        $this->crud->addField([
106
            'name'  => 'name',
107
            'label' => 'Name',
108
            'type'  => 'text',
109
        ]);
110
        $this->crud->addField([
111
            'name'        => 'placement',
112
            'label'       => 'Placement',
113
            'type'        => 'select2_from_array',
114
            'options'     => config('backpack.menu.placement'),
115
            'allows_null' => true,
116
            'default'     => null,
117
        ]);
118
    }
119
}
120