LevelCrudController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 38
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 7 1
A setupListOperation() 0 7 1
A setupUpdateOperation() 0 3 1
A setupCreateOperation() 0 9 1
1
<?php
2
3
namespace App\Http\Controllers\Admin;
4
5
use App\Http\Requests\LevelRequest as StoreRequest;
6
use App\Models\Level;
7
use Backpack\CRUD\app\Http\Controllers\CrudController;
8
use Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
9
use Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
10
use Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
11
use Backpack\CRUD\app\Library\CrudPanel\CrudPanelFacade as CRUD;
12
13
class LevelCrudController extends CrudController
14
{
15
    use 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\LevelCrudController: $model, $query, $entity_name_plural
Loading history...
16
    use 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\Admin\LevelCrudController.
Loading history...
17
    use 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\LevelCrudController: $entity_name, $model
Loading history...
18
19
    public function setup()
20
    {
21
        CRUD::setModel(Level::class);
22
        CRUD::setRoute(config('backpack.base.route_prefix').'/level');
23
        CRUD::setEntityNameStrings(__('level'), __('levels'));
24
        CRUD::addClause('withTrashed');
25
        CRUD::addButtonFromView('line', 'toggle', 'toggle', 'end');
26
    }
27
28
    protected function setupListOperation()
29
    {
30
        CRUD::addColumn(['name' => 'name',
31
            'label' => 'Name', ]);
32
        CRUD::addColumn(['name' => 'lms_id',
33
            'label' => 'LMS code',
34
            'type' => 'text', ],);
35
    }
36
37
    protected function setupCreateOperation()
38
    {
39
        CRUD::setValidation(StoreRequest::class);
40
        CRUD::addField(['name' => 'name',
41
            'label' => 'Name',
42
            'type' => 'text', ]);
43
        CRUD::addField(['name' => 'lms_id',
44
            'label' => 'LMS code',
45
            'type' => 'text', ],);
46
    }
47
48
    protected function setupUpdateOperation()
49
    {
50
        $this->setupCreateOperation();
51
    }
52
}
53