| Total Complexity | 4 |
| Total Lines | 69 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | class RoomCrudController extends CrudController |
||
| 15 | { |
||
| 16 | use ListOperation; |
||
|
|
|||
| 17 | use CreateOperation; |
||
| 18 | use UpdateOperation; |
||
| 19 | use DeleteOperation; |
||
| 20 | |||
| 21 | public function setup() |
||
| 22 | { |
||
| 23 | CRUD::setModel(Room::class); |
||
| 24 | CRUD::setRoute(config('backpack.base.route_prefix').'/room'); |
||
| 25 | CRUD::setEntityNameStrings(__('room'), __('rooms')); |
||
| 26 | } |
||
| 27 | |||
| 28 | protected function setupListOperation() |
||
| 29 | { |
||
| 30 | CRUD::setColumns([ |
||
| 31 | [ |
||
| 32 | // 1-n relationship |
||
| 33 | 'label' => 'Campus', |
||
| 34 | 'type' => 'relationship', |
||
| 35 | 'name' => 'campus', |
||
| 36 | 'attribute' => 'name', |
||
| 37 | ], |
||
| 38 | |||
| 39 | [ |
||
| 40 | 'name' => 'name', |
||
| 41 | 'label' => 'Name', |
||
| 42 | 'type' => 'text', |
||
| 43 | ], |
||
| 44 | |||
| 45 | [ |
||
| 46 | 'name' => 'capacity', |
||
| 47 | 'label' => 'Capacity', |
||
| 48 | 'type' => 'number', |
||
| 49 | ], |
||
| 50 | ]); |
||
| 51 | } |
||
| 52 | |||
| 53 | protected function setupCreateOperation() |
||
| 54 | { |
||
| 55 | CRUD::setValidation(StoreRequest::class); |
||
| 56 | CRUD::addFields([ |
||
| 57 | [ |
||
| 58 | // 1-n relationship |
||
| 59 | 'label' => 'Campus', |
||
| 60 | 'type' => 'select', |
||
| 61 | 'entity' => 'campus', |
||
| 62 | 'name' => 'campus_id', |
||
| 63 | 'attribute' => 'name', |
||
| 64 | ], |
||
| 65 | |||
| 66 | [ |
||
| 67 | 'name' => 'name', |
||
| 68 | 'label' => 'Name', |
||
| 69 | 'type' => 'text', |
||
| 70 | ], |
||
| 71 | |||
| 72 | [ |
||
| 73 | 'name' => 'capacity', |
||
| 74 | 'label' => 'Capacity', |
||
| 75 | 'type' => 'number', |
||
| 76 | ], |
||
| 77 | ]); |
||
| 78 | } |
||
| 79 | |||
| 80 | protected function setupUpdateOperation() |
||
| 83 | } |
||
| 84 | } |
||
| 85 |