From fe02bac6d6784d30f2457a5270ef4efc2bdf5ffe Mon Sep 17 00:00:00 2001 From: Bubka <858858+Bubka@users.noreply.github.com> Date: Wed, 28 Oct 2020 17:51:32 +0100 Subject: [PATCH] Complete Move to group feature --- app/Http/Controllers/GroupController.php | 21 +++++-- resources/js/views/Accounts.vue | 75 +++++++++++++++++------- resources/js/views/Groups.vue | 2 +- resources/lang/en/groups.php | 4 +- resources/sass/app.scss | 4 -- 5 files changed, 73 insertions(+), 33 deletions(-) diff --git a/app/Http/Controllers/GroupController.php b/app/Http/Controllers/GroupController.php index 5200fbea..6fb00da6 100644 --- a/app/Http/Controllers/GroupController.php +++ b/app/Http/Controllers/GroupController.php @@ -111,13 +111,24 @@ public function update(Request $request, $id) */ public function associateAccounts(Request $request) { + if( $request->input('groupId') > 0 ) { + + $twofaccounts = TwoFAccount::find($request->input('accountsIds')); + $group = Group::FindOrFail($request->input('groupId')); + + $group->twofaccounts()->saveMany($twofaccounts); + + return response()->json($group, 200); + } + else { + + TwoFAccount::whereIn('id', $request->input('accountsIds')) + ->update(['group_id' => NULL]); + + return response()->json(['message' => 'moved to null'], 200); + } - $twofaccounts = TwoFAccount::find($request->input('accountsIds')); - $group = Group::FindOrFail($request->input('groupId')); - - $group->twofaccounts()->saveMany($twofaccounts); - return response()->json($group, 200); } diff --git a/resources/js/views/Accounts.vue b/resources/js/views/Accounts.vue index 6af079a2..93f4f612 100644 --- a/resources/js/views/Accounts.vue +++ b/resources/js/views/Accounts.vue @@ -1,7 +1,7 @@