create toggleEmailNotifications method in user controller
This commit is contained in:
@@ -350,4 +350,18 @@ class UserController extends Controller
|
|||||||
return response()->json(['message' => "Server error"], 500);
|
return response()->json(['message' => "Server error"], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toggleEmailNotifications(Request $request, int $id): JsonResponse {
|
||||||
|
try {
|
||||||
|
$user = User::findOrFail($id);
|
||||||
|
$user->email_notifications = !$user->email_notifications ? 0 : 1;
|
||||||
|
$user->save();
|
||||||
|
|
||||||
|
return response()->json($user);
|
||||||
|
}catch(\Exception $e){
|
||||||
|
Log::info($e->getMessage());
|
||||||
|
return response()->json(['message' => "Server error"], 500);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user