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
Push — master ( c757b8...487d63 )
by Cristian
02:53
created

RoleCrudController::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 47
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
c 4
b 1
f 0
dl 0
loc 47
rs 9.0303
cc 3
eloc 32
nc 4
nop 0
1
<?php
2
3
namespace Backpack\PermissionManager\app\Http\Controllers;
4
5
use Backpack\CRUD\app\Http\Controllers\CrudController;
6
// VALIDATION
7
use Backpack\PermissionManager\app\Http\Requests\RoleCrudRequest as StoreRequest;
8
use Backpack\PermissionManager\app\Http\Requests\RoleCrudRequest as UpdateRequest;
9
10
class RoleCrudController extends CrudController
11
{
12
    public function __construct()
13
    {
14
        parent::__construct();
15
16
        $this->crud->setModel("Backpack\PermissionManager\app\Models\Role");
17
        $this->crud->setEntityNameStrings('role', 'roles');
18
        $this->crud->setRoute('admin/role');
19
        $this->crud->setColumns([
20
                [
21
                    'name'  => 'name',
22
                    'label' => 'Name',
23
                    'type'  => 'text',
24
                ],
25
                [
26
                    // n-n relationship (with pivot table)
27
                    'label'     => 'Permissions',
28
                    'type'      => 'select_multiple',
29
                    'name'      => 'permissions', // the method that defines the relationship in your Model
30
                    'entity'    => 'permissions', // the method that defines the relationship in your Model
31
                    'attribute' => 'name', // foreign key attribute that is shown to user
32
                    'model'     => "Backpack\PermissionManager\app\Models\Permission", // foreign key model
33
                    'pivot'     => true, // on create&update, do you need to add/delete pivot table entries?
34
                ],
35
            ]);
36
37
        $this->crud->addField([
38
                                'name'  => 'name',
39
                                'label' => 'Name',
40
                                'type'  => 'text',
41
                            ]);
42
        $this->crud->addField([
43
                                'label'     => 'Permissions',
44
                                'type'      => 'checklist',
45
                                'name'      => 'permissions',
46
                                'entity'    => 'permissions',
47
                                'attribute' => 'name',
48
                                'model'     => "Backpack\PermissionManager\app\Models\Permission",
49
                                'pivot'     => true,
50
                            ]);
51
52
        if (config('backpack.permissionmanager.allow_role_create') == false) {
53
            $this->crud->denyAccess('create');
54
        }
55
        if (config('backpack.permissionmanager.allow_role_update') == false) {
56
            $this->crud->denyAccess('update');
57
        }
58
    }
59
60
    public function store(StoreRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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...
61
    {
62
        return parent::storeCrud();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (storeCrud() instead of store()). Are you sure this is correct? If so, you might want to change this to $this->storeCrud().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
63
    }
64
65
    public function update(UpdateRequest $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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...
66
    {
67
        return parent::updateCrud();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (updateCrud() instead of update()). Are you sure this is correct? If so, you might want to change this to $this->updateCrud().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
68
    }
69
}
70