Passed
Push — feature/job-builder/job-detail... ( 58ee17...46caa1 )
by Xander
23:02 queued 12:47
created

DepartmentCrudController::setup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 34
ccs 12
cts 12
cp 1
rs 9.6
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Http\Controllers\Admin;
4
5
use Backpack\CRUD\app\Http\Controllers\CrudController;
6
// Validation.
7
use App\Http\Requests\DepartmentCrudRequest as StoreRequest;
8
use App\Http\Requests\DepartmentCrudRequest as UpdateRequest;
9
10
class DepartmentCrudController extends CrudController
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 2
    public function setup() : void
19
    {
20
        // Eloquent model to associate with this collection of views and controller actions.
21 2
        $this->crud->setModel('App\Models\Lookup\Department');
22
        // Custom backpack route.
23 2
        $this->crud->setRoute('admin/department');
24
        // Custom strings to display within the backpack UI.
25 2
        $this->crud->setEntityNameStrings('department', 'departments');
26
27
        // Add custom columns to the Department index view.
28 2
        $this->crud->addColumn([
29 2
            'name' => 'name',
30
            'type' => 'text',
31
            'label' => 'Name',
32
        ]);
33
34 2
        $this->crud->addColumn([
35 2
            'name' => 'impact',
36
            'type' => 'text',
37
            'label' => 'Impact',
38
            'orderable' => false,
39
        ]);
40
41
        // Add custom fields to the create/update views.
42 2
        $this->crud->addField([
43 2
            'name' => 'name',
44
            'type' => 'text',
45
            'label' => 'Name',
46
        ]);
47
48 2
        $this->crud->addField([
49 2
            'name' => 'impact',
50
            'type' => 'textarea',
51
            'label' => 'Impact',
52
        ]);
53 2
    }
54
55
    /**
56
     * Action for creating a new department in the database.
57
     *
58
     * @param  \App\Http\Requests\DepartmentCrudRequest $request Incoming form request.
59
     * @return \Illuminate\Http\RedirectResponse
60
     */
61
    public function store(StoreRequest $request) // phpcs:ignore
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

61
    public function store(/** @scrutinizer ignore-unused */ StoreRequest $request) // phpcs:ignore

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...
62
    {
63
        return parent::storeCrud();
64
    }
65
66
    /**
67
     * Action for updating an existing department in the database.
68
     *
69
     * @param  \App\Http\Requests\DepartmentCrudRequest $request Incoming form request.
70
     * @return \Illuminate\Http\RedirectResponse
71
     */
72
    public function update(UpdateRequest $request) // phpcs:ignore
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

72
    public function update(/** @scrutinizer ignore-unused */ UpdateRequest $request) // phpcs:ignore

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...
73
    {
74
        return parent::updateCrud();
75
    }
76
}
77