Code Duplication    Length = 22-22 lines in 2 locations

src/Controllers/PermissionController.php 2 locations

@@ 35-56 (lines=22) @@
32
        $grid->column('slug', trans('admin.slug'));
33
        $grid->column('name', trans('admin.name'));
34
35
        $grid->column('http_path', trans('admin.route'))->display(function ($path) {
36
            return collect(explode("\n", $path))->map(function ($path) {
37
                $method = $this->http_method ?: ['ANY'];
38
39
                if (Str::contains($path, ':')) {
40
                    list($method, $path) = explode(':', $path);
41
                    $method = explode(',', $method);
42
                }
43
44
                $method = collect($method)->map(function ($name) {
45
                    return strtoupper($name);
46
                })->map(function ($name) {
47
                    return "<span class='label label-primary'>{$name}</span>";
48
                })->implode('&nbsp;');
49
50
                if (!empty(config('admin.route.prefix'))) {
51
                    $path = '/'.trim(config('admin.route.prefix'), '/').$path;
52
                }
53
54
                return "<div style='margin-bottom: 5px;'>$method<code>$path</code></div>";
55
            })->implode('');
56
        });
57
58
        $grid->column('created_at', trans('admin.created_at'));
59
        $grid->column('updated_at', trans('admin.updated_at'));
@@ 87-108 (lines=22) @@
84
        $show->field('slug', trans('admin.slug'));
85
        $show->field('name', trans('admin.name'));
86
87
        $show->field('http_path', trans('admin.route'))->unescape()->as(function ($path) {
88
            return collect(explode("\r\n", $path))->map(function ($path) {
89
                $method = $this->http_method ?: ['ANY'];
90
91
                if (Str::contains($path, ':')) {
92
                    list($method, $path) = explode(':', $path);
93
                    $method = explode(',', $method);
94
                }
95
96
                $method = collect($method)->map(function ($name) {
97
                    return strtoupper($name);
98
                })->map(function ($name) {
99
                    return "<span class='label label-primary'>{$name}</span>";
100
                })->implode('&nbsp;');
101
102
                if (!empty(config('admin.route.prefix'))) {
103
                    $path = '/'.trim(config('admin.route.prefix'), '/').$path;
104
                }
105
106
                return "<div style='margin-bottom: 5px;'>$method<code>$path</code></div>";
107
            })->implode('');
108
        });
109
110
        $show->field('created_at', trans('admin.created_at'));
111
        $show->field('updated_at', trans('admin.updated_at'));