We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 1 |
| Paths | 1 |
| Total Lines | 61 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 12 | use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation; |
||
| 13 | use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation; |
||
| 14 | use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation; |
||
| 15 | use \Backpack\CRUD\app\Http\Controllers\Operations\ReorderOperation; |
||
| 16 | use \Backpack\CRUD\app\Http\Controllers\Operations\ShowOperation; |
||
| 17 | |||
| 18 | public function setup() |
||
| 19 | { |
||
| 20 | CRUD::setModel("Backpack\NewsCRUD\app\Models\Category"); |
||
| 21 | CRUD::setRoute(config('backpack.base.route_prefix', 'admin').'/category'); |
||
| 22 | CRUD::setEntityNameStrings('category', 'categories'); |
||
| 23 | } |
||
| 24 | |||
| 25 | protected function setupListOperation() |
||
| 26 | { |
||
| 27 | CRUD::addColumn('name'); |
||
| 28 | CRUD::addColumn('slug'); |
||
| 29 | CRUD::addColumn([ |
||
| 30 | 'label' => 'Parent', |
||
| 31 | 'type' => 'select', |
||
| 32 | 'name' => 'parent_id', |
||
| 33 | 'entity' => 'parent', |
||
| 34 | 'attribute' => 'name', |
||
| 35 | ]); |
||
| 36 | } |
||
| 37 | |||
| 38 | protected function setupShowOperation() |
||
| 39 | { |
||
| 40 | return $this->setupListOperation(); |
||
| 41 | } |
||
| 42 | |||
| 43 | protected function setupCreateOperation() |
||
| 44 | { |
||
| 45 | CRUD::setValidation(CategoryRequest::class); |
||
| 46 | |||
| 47 | CRUD::addField([ |
||
| 48 | 'name' => 'name', |
||
| 49 | 'label' => 'Name', |
||
| 50 | ]); |
||
| 51 | CRUD::addField([ |
||
| 52 | 'name' => 'slug', |
||
| 53 | 'label' => 'Slug (URL)', |
||
| 54 | 'type' => 'text', |
||
| 55 | 'hint' => 'Will be automatically generated from your name, if left empty.', |
||
| 56 | // 'disabled' => 'disabled' |
||
| 57 | ]); |
||
| 58 | CRUD::addField([ |
||
| 59 | 'label' => 'Parent', |
||
| 60 | 'type' => 'select', |
||
| 61 | 'name' => 'parent_id', |
||
| 62 | 'entity' => 'parent', |
||
| 63 | 'attribute' => 'name', |
||
| 64 | ]); |
||
| 65 | } |
||
| 66 | |||
| 67 | protected function setupUpdateOperation() |
||
| 68 | { |
||
| 69 | $this->setupCreateOperation(); |
||
| 70 | } |
||
| 71 | |||
| 72 | protected function setupReorderOperation() |
||
| 73 | { |
||
| 78 |