feature: send thankscard page
This commit is contained in:
@@ -97,8 +97,26 @@ class AdminController extends Controller
|
||||
public function update(UpdateUserRequest $request, string $msnv)
|
||||
{
|
||||
$user = $this->adminService->getUserByMsnv($msnv);
|
||||
$validatedData = $request->validated();
|
||||
|
||||
$this->adminService->updateUser($user, $request->validated());
|
||||
$this->adminService->updateUser($user, $validatedData);
|
||||
|
||||
$currentUser = auth()->user();
|
||||
if ($currentUser && $user->id === $currentUser->id && isset($validatedData['status']) && $validatedData['status'] == config('constants.STATUS_INACTIVE')) {
|
||||
auth()->logout();
|
||||
$request->session()->invalidate();
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
if ($request->expectsJson() || $request->ajax() || $request->wantsJson()) {
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Tài khoản của bạn đã chuyển sang trạng thái nghỉ việc. Bạn đã được đăng xuất.',
|
||||
'redirect' => route('login'),
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()->route('login')->with('success', 'Tài khoản của bạn đã chuyển sang trạng thái nghỉ việc. Bạn đã được đăng xuất.');
|
||||
}
|
||||
|
||||
if ($request->expectsJson()) {
|
||||
return response()->json([
|
||||
@@ -116,8 +134,19 @@ class AdminController extends Controller
|
||||
*/
|
||||
public function destroy(string $msnv): RedirectResponse
|
||||
{
|
||||
$user = $this->adminService->getUserByMsnv($msnv);
|
||||
|
||||
$this->adminService->deactivateUser($msnv);
|
||||
|
||||
$currentUser = auth()->user();
|
||||
if ($currentUser && $user->id === $currentUser->id) {
|
||||
auth()->logout();
|
||||
request()->session()->invalidate();
|
||||
request()->session()->regenerateToken();
|
||||
|
||||
return redirect()->route('login')->with('success', 'Tài khoản của bạn đã chuyển sang trạng thái nghỉ việc. Bạn đã được đăng xuất.');
|
||||
}
|
||||
|
||||
return redirect()->route('admin.users.index')->with('success', __('messages.user_deactivate_success'));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user