Skip to content

Commit 67a3217

Browse files
add new logic on controller to delete threads from user and from banning them
1 parent 8f65930 commit 67a3217

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

app/Http/Controllers/Admin/UsersController.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Http\Requests\BanRequest;
88
use App\Jobs\BanUser;
99
use App\Jobs\DeleteUser;
10+
use App\Jobs\DeleteUserThreads;
1011
use App\Jobs\UnbanUser;
1112
use App\Models\User;
1213
use App\Policies\UserPolicy;
@@ -39,6 +40,10 @@ public function ban(BanRequest $request, User $user): RedirectResponse
3940

4041
$this->dispatchSync(new BanUser($user, $request->get('reason')));
4142

43+
if ($request->get('delete_threads')) {
44+
$this->dispatchSync(new DeleteUserThreads($user));
45+
}
46+
4247
$this->success($user->name().' was banned!');
4348

4449
return redirect()->route('profile', $user->username());
@@ -65,4 +70,17 @@ public function delete(User $user): RedirectResponse
6570

6671
return redirect()->route('admin.users');
6772
}
73+
74+
public function deleteThreads(User $user): RedirectResponse
75+
{
76+
$this->authorize(UserPolicy::DELETE, $user);
77+
78+
$this->dispatchSync(new DeleteUserThreads($user));
79+
80+
$this->success($user->name().' threads were deleted!');
81+
82+
return redirect()->route('admin.users');
83+
}
84+
85+
6886
}

0 commit comments

Comments
 (0)