Passed
Push — feature/departments-admin-pane... ( d4c01f )
by Grant
32:56 queued 20:06
created

DepartmentCrudController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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

58
    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...
59
    {
60
        return parent::storeCrud();
61
    }
62
63
    /**
64
     * Action for updating an existing Department in the database.
65
     *
66
     * @param  \App\Http\Requests\DepartmentCrudRequest $request Incoming form request.
67
     * @return \Illuminate\Http\RedirectResponse
68
     */
69
    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

69
    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...
70
    {
71
        return parent::updateCrud();
72
    }
73
}
74