Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
Code Lines | 34 |
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 |
||
25 | public function setup() : void |
||
26 | { |
||
27 | // Eloquent model to associate with this collection |
||
28 | // of views and controller actions. |
||
29 | $this->crud->setModel('App\Models\Skill'); |
||
30 | // Custom backpack route. |
||
31 | $this->crud->setRoute('admin/skill'); |
||
32 | // Custom strings to display within the backpack UI, |
||
33 | // things like Create Skill, Delete Skills, etc. |
||
34 | $this->crud->setEntityNameStrings('skill', 'skills'); |
||
35 | |||
36 | $this->crud->operation(['create', 'update'], function () { |
||
37 | // Add custom fields to the create/update views. |
||
38 | $this->crud->addField([ |
||
39 | 'name' => 'name', |
||
40 | 'type' => 'text', |
||
41 | 'label' => 'Name', |
||
42 | ]); |
||
43 | |||
44 | $this->crud->addField([ |
||
45 | 'name' => 'description', |
||
46 | 'type' => 'textarea', |
||
47 | 'label' => 'Description' |
||
48 | ]); |
||
49 | |||
50 | $this->crud->addField([ |
||
51 | 'name' => 'skill_type_id', |
||
52 | 'label' => 'Type', |
||
53 | 'type' => 'select_from_array', |
||
54 | 'options' => SkillType::all()->pluck('name', 'id')->toArray(), |
||
55 | 'allow_null' => false, |
||
56 | ]); |
||
57 | |||
58 | $this->crud->addField([ |
||
59 | 'name' => 'classifications', |
||
60 | 'type' => 'select2_multiple', |
||
61 | 'label' => 'Classifications (select all that apply)', |
||
62 | 'entity' => 'skills', |
||
63 | 'attribute' => 'key', |
||
64 | 'model' => 'App\Models\Classification', |
||
65 | 'pivot' => true, |
||
66 | ]); |
||
67 | |||
68 | $this->crud->addField([ |
||
69 | 'name' => 'is_culture_skill', |
||
70 | 'label' => 'This is a culture skill', |
||
71 | 'type' => 'checkbox' |
||
72 | ]); |
||
73 | |||
74 | $this->crud->addField([ |
||
75 | 'name' => 'is_future_skill', |
||
76 | 'label' => 'This is a future skill', |
||
77 | 'type' => 'checkbox' |
||
78 | ]); |
||
201 |