Completed
Push — feature/user_input_newlines ( 7c3825...9ce77c )
by Tristan
15:58 queued 09:53
created

UserCrudController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 41
dl 0
loc 59
ccs 0
cts 25
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 4 1
A setup() 0 50 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace App\Http\Controllers\Admin;
4
5
use Backpack\CRUD\app\Http\Controllers\CrudController;
6
use App\Models\UserRole;
7
8
class UserCrudController extends CrudController
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class UserCrudController
Loading history...
9
{
10
    public function setup()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setup()
Loading history...
11
    {
12
        $this->crud->setModel("App\Models\User");
13
        $this->crud->setRoute("admin/user");
14
        $this->crud->setEntityNameStrings('user', 'users');
15
16
        $this->crud->denyAccess('create');
17
        $this->crud->denyAccess('delete');
18
19
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
20
            'name' => 'name',
21
            'type' => 'text',
22
            'label' => 'Name'
23
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
24
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
25
            'name' => 'email',
26
            'type' => 'text',
27
            'label' => 'Email'
28
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
29
        $this->crud->addColumn([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
30
            'name' => 'user_role.name',
31
            'type' => 'text',
32
            'label' => 'Role'
33
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
34
35
        $this->crud->addFilter([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
36
            'name' => 'user_role',
37
            'type' => 'select2',
38
            'label' => 'Role'
39
        ], function () {
40
            return UserRole::all()->keyBy('id')->pluck('name', 'id')->toArray();
41
        }, function ($value) {
42
            $this->crud->addClause('where', 'user_role_id', $value);
43
        });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
44
45
        $this->crud->addField([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
46
            'name' => 'name',
47
            'label' => "Name",
48
            'type' => 'text',
49
            'attributes' => [
50
                'readonly'=>'readonly'
51
            ]
52
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
53
        $this->crud->addField([
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
54
            'label' => "Role",
55
            'type' => 'select',
56
            'name' => 'user_role_id', // the db column for the foreign key
57
            'entity' => 'user_role', // the method that defines the relationship in your Model
58
            'attribute' => 'name', // foreign key attribute that is shown to user
59
            'model' => "App\Models\UserRole" // foreign key model
60
        ]);
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
61
    }
62
63
    public function update($request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

63
    public function update(/** @scrutinizer ignore-unused */ $request)

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

Loading history...
Coding Style introduced by
Missing doc comment for function update()
Loading history...
64
    {
65
        $response = parent::updateCrud();
66
        return $response;
67
    }
68
}
69