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 ( 766727...7a5d19 )
by Cristian
08:55
created

RoleCrudController::setup()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 46
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 8.9411
c 0
b 0
f 0
cc 3
eloc 31
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 setup()
13
    {
14
        $this->crud->setModel(config('laravel-permission.models.role'));
15
        $this->crud->setEntityNameStrings(trans('backpack::permissionmanager.role'), trans('backpack::permissionmanager.roles'));
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 129 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
16
        $this->crud->setRoute(config('backpack.base.route_prefix').'/role');
17
18
        $this->crud->setColumns([
19
            [
20
                'name'  => 'name',
21
                'label' => trans('backpack::permissionmanager.name'),
22
                'type'  => 'text',
23
            ],
24
            [
25
                // n-n relationship (with pivot table)
26
                'label'     => ucfirst(trans('backpack::permissionmanager.permission_plural')),
27
                'type'      => 'select_multiple',
28
                'name'      => 'permissions', // the method that defines the relationship in your Model
29
                'entity'    => 'permissions', // the method that defines the relationship in your Model
30
                'attribute' => 'name', // foreign key attribute that is shown to user
31
                'model'     => "Backpack\PermissionManager\app\Models\Permission", // foreign key model
32
                'pivot'     => true, // on create&update, do you need to add/delete pivot table entries?
33
            ],
34
        ]);
35
36
        $this->crud->addField([
37
            'name'  => 'name',
38
            'label' => trans('backpack::permissionmanager.name'),
39
            'type'  => 'text',
40
        ]);
41
        $this->crud->addField([
42
            'label'     => ucfirst(trans('backpack::permissionmanager.permission_plural')),
43
            'type'      => 'checklist',
44
            'name'      => 'permissions',
45
            'entity'    => 'permissions',
46
            'attribute' => 'name',
47
            'model'     => "Backpack\PermissionManager\app\Models\Permission",
48
            'pivot'     => true,
49
        ]);
50
51
        if (config('backpack.permissionmanager.allow_role_create') == false) {
52
            $this->crud->denyAccess('create');
53
        }
54
        if (config('backpack.permissionmanager.allow_role_update') == false) {
55
            $this->crud->denyAccess('update');
56
        }
57
    }
58
59
    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...
60
    {
61
        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...
62
    }
63
64
    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...
65
    {
66
        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...
67
    }
68
}
69