Passed
Pull Request — release/1.0.15 (#1655)
by Tristan
10:06 queued 02:47
created

ClassificationCrudController::setupListOperation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 0
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
    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\Adm...ificationCrudController: $model, $query, $entity_name_plural
Loading history...
12
    use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
0 ignored issues
show
Bug introduced by
The trait Backpack\CRUD\app\Http\C...rations\CreateOperation requires the property $entity_name which is not provided by App\Http\Controllers\Adm...ificationCrudController.
Loading history...
13
    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\Adm...ificationCrudController: $model, $entity_name
Loading history...
14
15
    /**
16
     * Prepare the admin interface by setting the associated
17
     * model, setting the route, and adding custom columns/fields.
18
     *
19
     * @return void
20
     */
21
    public function setup() : void
22
    {
23
        // Eloquent model to associate with this collection of views and controller actions.
24
        $this->crud->setModel('App\Models\Classification');
25
        // Custom backpack route.
26
        $this->crud->setRoute('admin/classification');
27
        // Custom strings to display within the backpack UI.
28
        $this->crud->setEntityNameStrings('classification', 'classifications');
29
30
        $this->crud->operation(['create', 'update'], function () {
31
            $this->crud->addField([
32
                'name' => 'key',
33
                'type' => 'text',
34
                'label' => 'Key',
35
            ]);
36
        });
37
    }
38
39
    public function setupListOperation()
1 ignored issue
show
Coding Style Documentation introduced by
Missing doc comment for function setupListOperation()
Loading history...
40
    {
41
        $this->crud->addColumn([
42
            'name' => 'id',
43
            'type' => 'text',
44
            'label' => 'ID',
45
        ]);
46
47
        $this->crud->addColumn([
48
            'name' => 'key',
49
            'type' => 'text',
50
            'label' => 'Key',
51
        ]);
52
    }
53
54
    public function setupCreateOperation()
1 ignored issue
show
Coding Style Documentation introduced by
Missing doc comment for function setupCreateOperation()
Loading history...
55
    {
56
        $this->crud->setValidation(StoreRequest::class);
57
    }
58
59
    public function setupUpdateOperation()
1 ignored issue
show
Coding Style Documentation introduced by
Missing doc comment for function setupUpdateOperation()
Loading history...
60
    {
61
        $this->crud->setValidation(UpdateRequest::class);
62
    }
63
}
64