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:07
created

MenuCrudController::setupListOperation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
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
 * @package Backpack\CRUD\app\Http\Controllers\Admin
12
 * @property-read \Backpack\CRUD\app\Library\CrudPanel\CrudPanel $crud
13
 */
14
class MenuCrudController extends CrudController
15
{
16
    use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
17
    use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
18
    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
19
    use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
20
    use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation;
21
22
    /**
23
     * Configure the CrudPanel object. Apply settings to all operations.
24
     *
25
     * @return void
26
     */
27
    public function setup()
28
    {
29
        $this->crud->setModel(\Backpack\CRUD\app\Models\Menu::class);
30
        $this->crud->setRoute(config('backpack.base.route_prefix').'/menu');
31
        $this->crud->setEntityNameStrings('menu', 'menus');
32
    }
33
34
    /**
35
     * Define what happens when the List operation is loaded.
36
     *
37
     * @see  https://backpackforlaravel.com/docs/crud-operation-list-entries
38
     * @return void
39
     */
40
    protected function setupListOperation()
41
    {
42
        $this->setupColumns(false);
43
44
        /**
45
         * Columns can be defined using the fluent syntax or array syntax:
46
         * - $this->crud->column('price')->type('number');
47
         * - $this->crud->addColumn(['name' => 'price', 'type' => 'number']);.
48
         */
49
    }
50
51
    protected function setupShowOperation()
52
    {
53
        $this->crud->set('show.setFromDb', false);
54
        $this->setupColumns(true);
55
    }
56
57
    /**
58
     * Define what happens when the Create operation is loaded.
59
     *
60
     * @see https://backpackforlaravel.com/docs/crud-operation-create
61
     * @return void
62
     */
63
    protected function setupCreateOperation()
64
    {
65
        $this->crud->setValidation(MenuRequest::class);
66
67
        $this->setupFields();
68
69
        /**
70
         * Fields can be defined using the fluent syntax or array syntax:
71
         * - $this->crud->field('price')->type('number');
72
         * - $this->crud->addField(['name' => 'price', 'type' => 'number']));.
73
         */
74
    }
75
76
    /**
77
     * Define what happens when the Update operation is loaded.
78
     *
79
     * @see https://backpackforlaravel.com/docs/crud-operation-update
80
     * @return void
81
     */
82
    protected function setupUpdateOperation()
83
    {
84
        $this->setupCreateOperation();
85
    }
86
87
    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...
88
    {
89
        $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...
90
91
        $this->crud->addColumn([
92
            'name'  => 'name',
93
            'label' => 'Name',
94
            'type'  => 'text',
95
        ]);
96
        $this->crud->addColumn([
97
            'name'    => 'placement',
98
            'label'   => 'Placement',
99
            'type'    => 'select_from_array',
100
            'options' => config('backpack.menu.placement'),
101
        ]);
102
    }
103
104
    private function setupFields()
105
    {
106
        $this->crud->addField([
107
            'name'  => 'name',
108
            'label' => 'Name',
109
            'type'  => 'text',
110
        ]);
111
        $this->crud->addField([
112
            'name'        => 'placement',
113
            'label'       => 'Placement',
114
            'type'        => 'select2_from_array',
115
            'options'     => config('backpack.menu.placement'),
116
            'allows_null' => true,
117
            'default'     => null,
118
        ]);
119
    }
120
}
121