Code Duplication    Length = 12-12 lines in 4 locations

app/Http/Controllers/CategoryController.php 2 locations

@@ 93-104 (lines=12) @@
90
        );
91
    }
92
93
    public function purgeAccounts($id)
94
    {
95
        $category = Category::findOrFail($id);
96
        $accounts = $category->accounts()->where('status', Account::ACCOUNT_DISABLE);
97
        if ($accounts->exists()) {
98
            $accounts->delete();
99
        }
100
        return redirect()->back()->with(
101
            'status',
102
            trans('categories.message.drop', ['category' => $category->name])
103
        );
104
    }
105
106
    public function disableAccounts($id)
107
    {
@@ 106-117 (lines=12) @@
103
        );
104
    }
105
106
    public function disableAccounts($id)
107
    {
108
        $category = Category::findOrFail($id);
109
        $accounts = $category->accounts()->where('status', Account::ACCOUNT_ENABLE)->get();
110
        foreach ($accounts as $account) {
111
            $account->disable();
112
        }
113
        return redirect()->back()->with(
114
            'status',
115
            trans('categories.message.disable', ['category' => $category->name])
116
        );
117
    }
118
}
119

app/Http/Controllers/GroupController.php 2 locations

@@ 98-109 (lines=12) @@
95
        );
96
    }
97
98
    public function purgeAccounts($id)
99
    {
100
        $group = Group::findOrFail($id);
101
        $accounts = Group::Find($id)->accounts()->where('status', Account::ACCOUNT_DISABLE);
102
        if ($accounts->exists()) {
103
            $accounts->delete();
104
        }
105
        return redirect()->back()->with(
106
            'status',
107
            trans('groups.message.drop', ['group' => $group->name])
108
        );
109
    }
110
111
    public function disableAccounts($id)
112
    {
@@ 111-122 (lines=12) @@
108
        );
109
    }
110
111
    public function disableAccounts($id)
112
    {
113
        $group = Group::findOrFail($id);
114
        $accounts = Group::Find($id)->accounts()->where('status', Account::ACCOUNT_ENABLE)->get();
115
        foreach ($accounts as $account) {
116
            $account->disable();
117
        }
118
        return redirect()->back()->with(
119
            'status',
120
            trans('groups.message.disable', ['group' => $group->name])
121
        );
122
    }
123
}
124