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

PermissionCrudController::setup()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 44
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 8.8571
c 0
b 0
f 0
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\PermissionCrudRequest as StoreRequest;
8
use Backpack\PermissionManager\app\Http\Requests\PermissionCrudRequest as UpdateRequest;
9
10
class PermissionCrudController extends CrudController
11
{
12
    public function setup()
13
    {
14
        $this->crud->setModel(config('laravel-permission.models.permission'));
15
        $this->crud->setEntityNameStrings(trans('backpack::permissionmanager.permission_singular'), trans('backpack::permissionmanager.permission_plural'));
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 156 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').'/permission');
17
18
19
        $this->crud->addColumn([
20
            'name'  => 'name',
21
            'label' => trans('backpack::permissionmanager.name'),
22
            'type'  => 'text',
23
        ]);
24
        $this->crud->addColumn([ // n-n relationship (with pivot table)
25
            'label'     => trans('backpack::permissionmanager.roles_have_permission'),
26
            'type'      => 'select_multiple',
27
            'name'      => 'roles',
28
            'entity'    => 'roles',
29
            'attribute' => 'name',
30
            'model'     => "Backpack\PermissionManager\app\Models\Role",
31
            'pivot'     => true,
32
        ]);
33
34
        $this->crud->addField([
35
            'name'  => 'name',
36
            'label' => trans('backpack::permissionmanager.name'),
37
            'type'  => 'text',
38
        ]);
39
        $this->crud->addField([
40
            'label'     => trans('backpack::permissionmanager.roles'),
41
            'type'      => 'checklist',
42
            'name'      => 'roles',
43
            'entity'    => 'roles',
44
            'attribute' => 'name',
45
            'model'     => "Backpack\PermissionManager\app\Models\Role",
46
            'pivot'     => true,
47
        ]);
48
49
        if (!config('backpack.permissionmanager.allow_permission_create')) {
50
            $this->crud->denyAccess('create');
51
        }
52
        if (!config('backpack.permissionmanager.allow_permission_update')) {
53
            $this->crud->denyAccess('update');
54
        }
55
    }
56
57
    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...
58
    {
59
        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...
60
    }
61
62
    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...
63
    {
64
        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...
65
    }
66
}
67