mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	add balance payment
This commit is contained in:
		| @@ -47,4 +47,20 @@ class UserService | ||||
|     { | ||||
|         return User::all(); | ||||
|     } | ||||
|  | ||||
|     public function addBalance(int $userId, int $balance):bool | ||||
|     { | ||||
|         $user = User::find($userId); | ||||
|         if (!$user) { | ||||
|             return false; | ||||
|         } | ||||
|         $user->balance = $user->balance + $balance; | ||||
|         if ($user->balance < 0) { | ||||
|             return false; | ||||
|         } | ||||
|         if (!$user->save()) { | ||||
|             return false; | ||||
|         } | ||||
|         return true; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user