Code Duplication    Length = 20-21 lines in 2 locations

src/Commands/ResourceCommand.php 2 locations

@@ 283-303 (lines=21) @@
280
        $stub = $this->files->get($stub);
281
        $replaces = [];
282
283
        if ($file === 'form') {
284
            $columns = $this->getModelFillableColumns(
285
                $this->getNamespacedModel($this->argument('model')),
286
                true
287
            );
288
            $html = '';
289
290
            foreach ($columns as $column) {
291
                $html .= str_replace([
292
                    '{{ column }}', '{{ model }}', '{{ variable }}'
293
                ], [
294
                    $column, $name, Str::singular($name)
295
                ], $this->files->get(
296
                    $this->resolveStubPath('/stubs/views/form-input.stub')
297
                ));
298
            }
299
300
            $replaces = [
301
                '{{ columns }}' => $html
302
            ];
303
        }
304
305
        if ($file === 'table') {
306
            $columns = $this->getModelFillableColumns(
@@ 305-324 (lines=20) @@
302
            ];
303
        }
304
305
        if ($file === 'table') {
306
            $columns = $this->getModelFillableColumns(
307
                $this->getNamespacedModel($this->argument('model'))
308
            );
309
            $html = '';
310
311
            foreach ($columns as $column) {
312
                $html .= str_replace([
313
                    '{{ column }}', '{{ model }}', '{{ variable }}'
314
                ], [
315
                    $column, $name, Str::singular($name)
316
                ], $this->files->get(
317
                    $this->resolveStubPath('/stubs/views/table-column.stub')
318
                ));
319
            }
320
321
            $replaces = [
322
                '{{ columns }}' => $html
323
            ];
324
        }
325
326
        return str_replace(array_keys($replaces), array_values($replaces), $stub);
327
    }