Completed
Push — master ( 20aa8d...02ffc1 )
by David
02:49
created
src/Helpers/CrudApi.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -146,6 +146,9 @@
 block discarded – undo
146 146
         return $jsMethod;
147 147
     }
148 148
 
149
+    /**
150
+     * @param string $type
151
+     */
149 152
     public function renderFields($type, $fields = [])
150 153
     {
151 154
         if (empty($fields)) {
Please login to merge, or discard this patch.
Switch Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
     private function modalUrl($type)
128 128
     {
129 129
         switch ($type) {
130
-        case 'edit':
131
-            $action = 'update';
132
-            break;
133
-        default:
134
-            $action = $type;
135
-            break;
130
+            case 'edit':
131
+                $action = 'update';
132
+                break;
133
+            default:
134
+                $action = $type;
135
+                break;
136 136
         }
137 137
 
138 138
         return route('crudapi.'.$action.'.item', $this->model);
@@ -154,76 +154,76 @@  discard block
 block discarded – undo
154 154
         $output = '';
155 155
 
156 156
         switch ($type) {
157
-        case 'form-create':
158
-            $output .= $this->fieldHelper->formCreate($fields);
159
-            break;
160
-        case 'form-edit':
161
-            foreach ($fields as $f) {
162
-                $ucF = ucfirst($f);
157
+            case 'form-create':
158
+                $output .= $this->fieldHelper->formCreate($fields);
159
+                break;
160
+            case 'form-edit':
161
+                foreach ($fields as $f) {
162
+                    $ucF = ucfirst($f);
163 163
 
164
-                $input_attr = [
165
-                    'class' => 'form-control',
166
-                    'id' => 'editItem'.$ucF,
167
-                    'name' => $f,
168
-                ];
164
+                    $input_attr = [
165
+                        'class' => 'form-control',
166
+                        'id' => 'editItem'.$ucF,
167
+                        'name' => $f,
168
+                    ];
169 169
 
170
-                $output .= '<fieldset class="form-group">';
170
+                    $output .= '<fieldset class="form-group">';
171 171
 
172
-                $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>';
172
+                    $output .= '<label for="'.$input_attr['id'].'">'.$ucF.'</label>';
173 173
 
174
-                if ($this->fieldHelper->isIdField($f)) {
175
-                    $input_attr['type'] = 'select';
174
+                    if ($this->fieldHelper->isIdField($f)) {
175
+                        $input_attr['type'] = 'select';
176 176
 
177
-                    $output .= '<select ';
178
-                    foreach ($input_attr as $attr => $value) {
179
-                        $output .= "{$attr}='{$value}'";
180
-                    }
177
+                        $output .= '<select ';
178
+                        foreach ($input_attr as $attr => $value) {
179
+                            $output .= "{$attr}='{$value}'";
180
+                        }
181 181
 
182
-                    $relation = $this->getRelatedModel($f);
183
-                    $output .= '>';
182
+                        $relation = $this->getRelatedModel($f);
183
+                        $output .= '>';
184 184
 
185
-                    $output .= $this->getRelatedOptions($relation);
186
-                    $output .= '</select>';
187
-                } else {
188
-                    $input_attr['type'] = 'text';
185
+                        $output .= $this->getRelatedOptions($relation);
186
+                        $output .= '</select>';
187
+                    } else {
188
+                        $input_attr['type'] = 'text';
189 189
 
190
-                    $output .= '<input ';
191
-                    foreach ($input_attr as $attr => $value) {
192
-                        $output .= "{$attr}='{$value}'";
190
+                        $output .= '<input ';
191
+                        foreach ($input_attr as $attr => $value) {
192
+                            $output .= "{$attr}='{$value}'";
193
+                        }
194
+                        $output .= '>';
193 195
                     }
194
-                    $output .= '>';
195
-                }
196 196
 
197
-                $output .= '</fieldset>';
198
-            }
199
-            break;
200
-        case 'table-headings':
201
-            $output .= $this->fieldHelper->tableHeadings($fields);
202
-            break;
203
-        case 'table-content':
204
-            foreach ($fields as $f) {
205
-                if ($this->fieldHelper->isIdField($f)) {
206
-                    $display = $this->getRelatedDisplay($f);
207
-                    $output .= '<td>'.$display.'</td>';
208
-                } else {
209
-                    $output .= '<td>'.$this->instance->$f.'</td>';
197
+                    $output .= '</fieldset>';
210 198
                 }
211
-            }
212
-            break;
213
-            // JavaScript Variables
214
-        case 'js-var':
215
-            foreach ($fields as $f) {
216
-                $output .= 'var '.$f.' = '.$this->instance->$f.'; ';
217
-            }
218
-            break;
219
-        case 'js-modal-create':
220
-            foreach ($fields as $f) {
221
-                $output .= '"'.$f.'": $(\'#createItem'.$f.'\').val(), ';
222
-            }
223
-            break;
224
-        default:
225
-            return;
226 199
                 break;
200
+            case 'table-headings':
201
+                $output .= $this->fieldHelper->tableHeadings($fields);
202
+                break;
203
+            case 'table-content':
204
+                foreach ($fields as $f) {
205
+                    if ($this->fieldHelper->isIdField($f)) {
206
+                        $display = $this->getRelatedDisplay($f);
207
+                        $output .= '<td>'.$display.'</td>';
208
+                    } else {
209
+                        $output .= '<td>'.$this->instance->$f.'</td>';
210
+                    }
211
+                }
212
+                break;
213
+                // JavaScript Variables
214
+            case 'js-var':
215
+                foreach ($fields as $f) {
216
+                    $output .= 'var '.$f.' = '.$this->instance->$f.'; ';
217
+                }
218
+                break;
219
+            case 'js-modal-create':
220
+                foreach ($fields as $f) {
221
+                    $output .= '"'.$f.'": $(\'#createItem'.$f.'\').val(), ';
222
+                }
223
+                break;
224
+            default:
225
+                return;
226
+                    break;
227 227
         }
228 228
 
229 229
         echo $output;
@@ -284,17 +284,17 @@  discard block
 block discarded – undo
284 284
         $class = get_class($field);
285 285
 
286 286
         switch ($class) {
287
-        case 'App\\Helpers\\CrudApi':
288
-            break;
289
-        case 'App\\Indicator':
290
-            return $field->indicator;
291
-                break;
292
-        case 'Taskforcedev\\CrudApi\\Helpers\\CrudApi':
293
-            return false;
294
-                break;
295
-        default:
296
-            return $field->name;
287
+            case 'App\\Helpers\\CrudApi':
297 288
                 break;
289
+            case 'App\\Indicator':
290
+                return $field->indicator;
291
+                    break;
292
+            case 'Taskforcedev\\CrudApi\\Helpers\\CrudApi':
293
+                return false;
294
+                    break;
295
+            default:
296
+                return $field->name;
297
+                    break;
298 298
         }
299 299
     }
300 300
 
Please login to merge, or discard this patch.