Passed
Push — master ( cd2cd2...6fd81b )
by Tristan
25:03 queued 13:24
created

ClassificationCrudController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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

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

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