Passed
Push — master ( 6ceee8...d4902a )
by Tristan
20:51 queued 08:57
created

ManagerCrudController::setupListOperation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 45
Code Lines 34

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 34
dl 0
loc 45
ccs 0
cts 6
cp 0
rs 9.376
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace App\Http\Controllers\Admin;
4
5
use Backpack\CRUD\app\Http\Controllers\CrudController;
6
7
class ManagerCrudController extends CrudController
8
{
9
    use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
0 ignored issues
show
introduced by
The trait Backpack\CRUD\app\Http\C...perations\ListOperation requires some properties which are not provided by App\Http\Controllers\Admin\ManagerCrudController: $model, $query, $entity_name_plural
Loading history...
10
    use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
0 ignored issues
show
introduced by
The trait Backpack\CRUD\app\Http\C...rations\UpdateOperation requires some properties which are not provided by App\Http\Controllers\Admin\ManagerCrudController: $model, $entity_name
Loading history...
11
12
    /**
13
     * Prepare the admin interface by setting the associated
14
     * model, setting the route, and adding custom columns/fields.
15
     *
16
     * @return void
17
     */
18
    public function setup() : void
19
    {
20
        $this->crud->setModel('App\Models\User');
21
        $this->crud->setRoute('admin/manager');
22
        $this->crud->setEntityNameStrings('manager', 'managers');
23
24
        // Don't show 'basic' users.
25
        $this->crud->addClause('whereIn', 'user_role_id', [2, 3]);
26
    }
27
28
    public function setupListOperation()
29
    {
30
        $this->crud->removeButton('update');
31
32
        $this->crud->addColumn([
33
            'name' => 'manager.id',
34
            'key' => 'manager_id',
35
            'type' => 'number',
36
            'label' => 'ID'
37
        ]);
38
        $this->crud->addColumn([
39
            'name' => 'full_name',
40
            'key' => 'manager_name',
41
            'type' => 'text',
42
            'label' => 'Name'
43
        ]);
44
        $this->crud->addColumn([
45
            'name' => 'user_role.name',
46
            'type' => 'text',
47
            'key' => 'user_role_name',
48
            'label' => 'Role'
49
        ]);
50
        $this->crud->addColumn([
51
            'name' => 'email',
52
            'key' => 'manager_email',
53
            'type' => 'text',
54
            'label' => 'Email'
55
        ]);
56
        $this->crud->addColumn([
57
            'name' => 'gov_email',
58
            'key' => 'government_email',
59
            'type' => 'text',
60
            'label' => 'Government Email'
61
        ]);
62
        $this->crud->addColumn([
63
            'name' => 'manager.department.name',
64
            'key' => 'manager_department',
65
            'type' => 'text',
66
            'label' => 'Department',
67
            'limit' => 70
68
        ]);
69
70
        // Add the custom blade button found in resources/views/vendor/backpack/crud/buttons/profile_edit.blade.php.
71
        $this->crud->addButtonFromView('line', 'create_job_poster', 'create_job_poster', 'beginning');
72
        $this->crud->addButtonFromView('line', 'profile_edit', 'profile_edit', 'end');
73
    }
74
}
75