mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 01:11:46 +08:00 
			
		
		
		
	update: language more
This commit is contained in:
		| @@ -11,25 +11,25 @@ class CouponController extends Controller | ||||
|     public function check(Request $request) | ||||
|     { | ||||
|         if (empty($request->input('code'))) { | ||||
|             abort(500, __('user.coupon.check.coupon_not_empty')); | ||||
|             abort(500, __('Coupon cannot be empty')); | ||||
|         } | ||||
|         $coupon = Coupon::where('code', $request->input('code'))->first(); | ||||
|         if (!$coupon) { | ||||
|             abort(500, __('user.coupon.check.coupon_invalid')); | ||||
|             abort(500, __('Invalid coupon')); | ||||
|         } | ||||
|         if ($coupon->limit_use <= 0 && $coupon->limit_use !== NULL) { | ||||
|             abort(500, __('user.coupon.check.coupon_not_available_by_number')); | ||||
|             abort(500, __('This coupon is no longer available')); | ||||
|         } | ||||
|         if (time() < $coupon->started_at) { | ||||
|             abort(500, __('user.coupon.check.coupon_not_available_by_time')); | ||||
|             abort(500, __('This coupon has not yet started')); | ||||
|         } | ||||
|         if (time() > $coupon->ended_at) { | ||||
|             abort(500, __('user.coupon.check.coupon_expired')); | ||||
|             abort(500, __('This coupon has expired')); | ||||
|         } | ||||
|         if ($coupon->limit_plan_ids) { | ||||
|             $limitPlanIds = json_decode($coupon->limit_plan_ids); | ||||
|             if (!in_array($request->input('plan_id'), $limitPlanIds)) { | ||||
|                 abort(500, __('user.coupon.check.coupon_limit_plan')); | ||||
|                 abort(500, __('The coupon code cannot be used for this subscription')); | ||||
|             } | ||||
|         } | ||||
|         return response([ | ||||
|   | ||||
| @@ -14,7 +14,7 @@ class InviteController extends Controller | ||||
|     public function save(Request $request) | ||||
|     { | ||||
|         if (InviteCode::where('user_id', $request->session()->get('id'))->where('status', 0)->count() >= config('v2board.invite_gen_limit', 5)) { | ||||
|             abort(500, __('user.invite.save.invite_create_limit')); | ||||
|             abort(500, __('The maximum number of creations has been reached')); | ||||
|         } | ||||
|         $inviteCode = new InviteCode(); | ||||
|         $inviteCode->user_id = $request->session()->get('id'); | ||||
|   | ||||
| @@ -17,15 +17,15 @@ class KnowledgeController extends Controller | ||||
|                 ->where('show', 1) | ||||
|                 ->first() | ||||
|                 ->toArray(); | ||||
|             if (!$knowledge) abort(500, __('user.knowledge.fetch.knowledge_not_exist')); | ||||
|             if (!$knowledge) abort(500, __('Article does not exist')); | ||||
|             $user = User::find($request->session()->get('id')); | ||||
|             $userService = new UserService(); | ||||
|             if ($userService->isAvailable($user)) { | ||||
|                 $appleId = config('v2board.apple_id'); | ||||
|                 $appleIdPassword = config('v2board.apple_id_password'); | ||||
|             } else { | ||||
|                 $appleId = __('user.knowledge.fetch.apple_id_must_be_plan'); | ||||
|                 $appleIdPassword = __('user.knowledge.fetch.apple_id_must_be_plan'); | ||||
|                 $appleId = __('No active subscription. Unable to use our provided Apple ID'); | ||||
|                 $appleIdPassword = __('No active subscription. Unable to use our provided Apple ID'); | ||||
|                 $this->formatAccessData($knowledge['body']); | ||||
|             } | ||||
|             $subscribeUrl = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token']; | ||||
| @@ -63,7 +63,7 @@ class KnowledgeController extends Controller | ||||
|         function getBetween($input, $start, $end){$substr = substr($input, strlen($start)+strpos($input, $start),(strlen($input) - strpos($input, $end))*(-1));return $substr;} | ||||
|         $accessData = getBetween($body, '<!--access start-->', '<!--access end-->'); | ||||
|         if ($accessData) { | ||||
|             $body = str_replace($accessData, '<div class="v2board-no-access">'. __('user.knowledge.formatAccessData.no_access') .'</div>', $body); | ||||
|             $body = str_replace($accessData, '<div class="v2board-no-access">'. __('You must have a valid subscription to view content in this area') .'</div>', $body); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -52,12 +52,12 @@ class OrderController extends Controller | ||||
|             ->where('trade_no', $request->input('trade_no')) | ||||
|             ->first(); | ||||
|         if (!$order) { | ||||
|             abort(500, __('user.order.details.order_not_exist')); | ||||
|             abort(500, __('Order does not exist or has been paid')); | ||||
|         } | ||||
|         $order['plan'] = Plan::find($order->plan_id); | ||||
|         $order['try_out_plan_id'] = (int)config('v2board.try_out_plan_id'); | ||||
|         if (!$order['plan']) { | ||||
|             abort(500, __('user.order.details.plan_not_exist')); | ||||
|             abort(500, __('Subscription plan does not exist')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => $order | ||||
| @@ -68,38 +68,38 @@ class OrderController extends Controller | ||||
|     { | ||||
|         $userService = new UserService(); | ||||
|         if ($userService->isNotCompleteOrderByUserId($request->session()->get('id'))) { | ||||
|             abort(500, __('user.order.save.exist_open_order')); | ||||
|             abort(500, __('You have an unpaid or pending order, please try again later or cancel it')); | ||||
|         } | ||||
|  | ||||
|         $plan = Plan::find($request->input('plan_id')); | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|  | ||||
|         if (!$plan) { | ||||
|             abort(500, __('user.order.save.plan_not_exist')); | ||||
|             abort(500, __('Subscription plan does not exist')); | ||||
|         } | ||||
|  | ||||
|         if ((!$plan->show && !$plan->renew) || (!$plan->show && $user->plan_id !== $plan->id)) { | ||||
|             if ($request->input('cycle') !== 'reset_price') { | ||||
|                 abort(500, __('user.order.save.plan_stop_sell')); | ||||
|                 abort(500, __('This subscription has been sold out, please choose another subscription')); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (!$plan->renew && $user->plan_id == $plan->id && $request->input('cycle') !== 'reset_price') { | ||||
|             abort(500, __('user.order.save.plan_stop_renew')); | ||||
|             abort(500, __('This subscription cannot be renewed, please change to another subscription')); | ||||
|         } | ||||
|  | ||||
|         if ($plan[$request->input('cycle')] === NULL) { | ||||
|             abort(500, __('user.order.save.plan_stop')); | ||||
|             abort(500, __('This payment cycle cannot be purchased, please choose another cycle')); | ||||
|         } | ||||
|  | ||||
|         if ($request->input('cycle') === 'reset_price') { | ||||
|             if ($user->expired_at <= time() || !$user->plan_id) { | ||||
|                 abort(500, __('user.order.save.plan_exist_not_buy_package')); | ||||
|                 abort(500, __('Subscription has expired or no active subscription, unable to purchase Data Reset Package')); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (!$plan->show && $plan->renew && !$userService->isAvailable($user)) { | ||||
|             abort(500, __('user.order.save.plan_expired')); | ||||
|             abort(500, __('This subscription has expired, please change to another subscription')); | ||||
|         } | ||||
|  | ||||
|         DB::beginTransaction(); | ||||
| @@ -115,7 +115,7 @@ class OrderController extends Controller | ||||
|             $couponService = new CouponService($request->input('coupon_code')); | ||||
|             if (!$couponService->use($order)) { | ||||
|                 DB::rollBack(); | ||||
|                 abort(500, __('user.order.save.coupon_use_failed')); | ||||
|                 abort(500, __('Coupon failed')); | ||||
|             } | ||||
|             $order->coupon_id = $couponService->getId(); | ||||
|         } | ||||
| @@ -130,14 +130,14 @@ class OrderController extends Controller | ||||
|             if ($remainingBalance > 0) { | ||||
|                 if (!$userService->addBalance($order->user_id, - $order->total_amount)) { | ||||
|                     DB::rollBack(); | ||||
|                     abort(500, __('user.order.save.insufficient_balance')); | ||||
|                     abort(500, __('Insufficient balance')); | ||||
|                 } | ||||
|                 $order->balance_amount = $order->total_amount; | ||||
|                 $order->total_amount = 0; | ||||
|             } else { | ||||
|                 if (!$userService->addBalance($order->user_id, - $user->balance)) { | ||||
|                     DB::rollBack(); | ||||
|                     abort(500, __('user.order.save.insufficient_balance')); | ||||
|                     abort(500, __('Insufficient balance')); | ||||
|                 } | ||||
|                 $order->balance_amount = $user->balance; | ||||
|                 $order->total_amount = $order->total_amount - $user->balance; | ||||
| @@ -146,7 +146,7 @@ class OrderController extends Controller | ||||
|  | ||||
|         if (!$order->save()) { | ||||
|             DB::rollback(); | ||||
|             abort(500, __('user.order.save.order_create_failed')); | ||||
|             abort(500, __('Failed to create order')); | ||||
|         } | ||||
|  | ||||
|         DB::commit(); | ||||
| @@ -165,7 +165,7 @@ class OrderController extends Controller | ||||
|             ->where('status', 0) | ||||
|             ->first(); | ||||
|         if (!$order) { | ||||
|             abort(500, __('user.order.checkout.order_not_exist_or_paid')); | ||||
|             abort(500, __('Order does not exist or has been paid')); | ||||
|         } | ||||
|         // free process | ||||
|         if ($order->total_amount <= 0) { | ||||
| @@ -178,7 +178,7 @@ class OrderController extends Controller | ||||
|             ]); | ||||
|         } | ||||
|         $payment = Payment::find($method); | ||||
|         if (!$payment || $payment->enable !== 1) abort(500, __('user.order.checkout.pay_method_not_use')); | ||||
|         if (!$payment || $payment->enable !== 1) abort(500, __('Payment method is not available')); | ||||
|         $paymentService = new PaymentService($payment->payment, $payment->id); | ||||
|         $result = $paymentService->pay([ | ||||
|             'trade_no' => $tradeNo, | ||||
| @@ -200,7 +200,7 @@ class OrderController extends Controller | ||||
|             ->where('user_id', $request->session()->get('id')) | ||||
|             ->first(); | ||||
|         if (!$order) { | ||||
|             abort(500, __('user.order.check.order_not_exist')); | ||||
|             abort(500, __('Order does not exist')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => $order->status | ||||
| @@ -224,20 +224,20 @@ class OrderController extends Controller | ||||
|     public function cancel(Request $request) | ||||
|     { | ||||
|         if (empty($request->input('trade_no'))) { | ||||
|             abort(500, __('user.order.cancel.params_wrong')); | ||||
|             abort(500, __('Invalid parameter')); | ||||
|         } | ||||
|         $order = Order::where('trade_no', $request->input('trade_no')) | ||||
|             ->where('user_id', $request->session()->get('id')) | ||||
|             ->first(); | ||||
|         if (!$order) { | ||||
|             abort(500, __('user.order.cancel.order_not_exist')); | ||||
|             abort(500, __('Order does not exist')); | ||||
|         } | ||||
|         if ($order->status !== 0) { | ||||
|             abort(500, __('user.order.cancel.only_cancel_pending_order')); | ||||
|             abort(500, __('You can only cancel pending orders')); | ||||
|         } | ||||
|         $orderService = new OrderService($order); | ||||
|         if (!$orderService->cancel()) { | ||||
|             abort(500, __('user.order.cancel.cancel_failed')); | ||||
|             abort(500, __('Cancel failed')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => true | ||||
|   | ||||
| @@ -14,7 +14,7 @@ class PlanController extends Controller | ||||
|             $plan = Plan::where('id', $request->input('id')) | ||||
|                 ->first(); | ||||
|             if (!$plan) { | ||||
|                 abort(500, __('user.plan.fetch.plan_not_exist')); | ||||
|                 abort(500, __('Subscription plan does not exist')); | ||||
|             } | ||||
|             return response([ | ||||
|                 'data' => $plan | ||||
|   | ||||
| @@ -3,7 +3,9 @@ | ||||
| namespace App\Http\Controllers\User; | ||||
|  | ||||
| use App\Http\Controllers\Controller; | ||||
| use App\Models\User; | ||||
| use App\Services\TelegramService; | ||||
| use Illuminate\Http\Request; | ||||
|  | ||||
| class TelegramController extends Controller | ||||
| { | ||||
| @@ -17,4 +19,9 @@ class TelegramController extends Controller | ||||
|             ] | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
|     public function unbind(Request $request) | ||||
|     { | ||||
|         $user = User::where('user_id', $request->session()->get('id'))->first(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -23,7 +23,7 @@ class TicketController extends Controller | ||||
|                 ->where('user_id', $request->session()->get('id')) | ||||
|                 ->first(); | ||||
|             if (!$ticket) { | ||||
|                 abort(500, __('user.ticket.fetch.ticket_not_exist')); | ||||
|                 abort(500, __('Ticket does not exist')); | ||||
|             } | ||||
|             $ticket['message'] = TicketMessage::where('ticket_id', $ticket->id)->get(); | ||||
|             for ($i = 0; $i < count($ticket['message']); $i++) { | ||||
| @@ -56,7 +56,7 @@ class TicketController extends Controller | ||||
|     { | ||||
|         DB::beginTransaction(); | ||||
|         if ((int)Ticket::where('status', 0)->where('user_id', $request->session()->get('id'))->count()) { | ||||
|             abort(500, __('user.ticket.save.exist_other_open_ticket')); | ||||
|             abort(500, __('There are other unresolved tickets')); | ||||
|         } | ||||
|         $ticket = Ticket::create(array_merge($request->only([ | ||||
|             'subject', | ||||
| @@ -67,7 +67,7 @@ class TicketController extends Controller | ||||
|         ])); | ||||
|         if (!$ticket) { | ||||
|             DB::rollback(); | ||||
|             abort(500, __('user.ticket.save.ticket_create_failed')); | ||||
|             abort(500, __('Failed to open ticket')); | ||||
|         } | ||||
|         $ticketMessage = TicketMessage::create([ | ||||
|             'user_id' => $request->session()->get('id'), | ||||
| @@ -76,7 +76,7 @@ class TicketController extends Controller | ||||
|         ]); | ||||
|         if (!$ticketMessage) { | ||||
|             DB::rollback(); | ||||
|             abort(500, __('user.ticket.save.ticket_create_failed')); | ||||
|             abort(500, __('Failed to open ticket')); | ||||
|         } | ||||
|         DB::commit(); | ||||
|         $this->sendNotify($ticket, $ticketMessage); | ||||
| @@ -88,22 +88,22 @@ class TicketController extends Controller | ||||
|     public function reply(Request $request) | ||||
|     { | ||||
|         if (empty($request->input('id'))) { | ||||
|             abort(500, __('user.ticket.reply.params_wrong')); | ||||
|             abort(500, __('Invalid parameter')); | ||||
|         } | ||||
|         if (empty($request->input('message'))) { | ||||
|             abort(500, __('user.ticket.reply.message_not_empty')); | ||||
|             abort(500, __('Message cannot be empty')); | ||||
|         } | ||||
|         $ticket = Ticket::where('id', $request->input('id')) | ||||
|             ->where('user_id', $request->session()->get('id')) | ||||
|             ->first(); | ||||
|         if (!$ticket) { | ||||
|             abort(500, __('user.ticket.reply.ticket_not_exist')); | ||||
|             abort(500, __('Ticket does not exist')); | ||||
|         } | ||||
|         if ($ticket->status) { | ||||
|             abort(500, __('user.ticket.reply.ticket_close_not_reply')); | ||||
|             abort(500, __('The ticket is closed and cannot be replied')); | ||||
|         } | ||||
|         if ($request->session()->get('id') == $this->getLastMessage($ticket->id)->user_id) { | ||||
|             abort(500, __('user.ticket.reply.wait_reply')); | ||||
|             abort(500, __('Please wait for the technical enginneer to reply')); | ||||
|         } | ||||
|         DB::beginTransaction(); | ||||
|         $ticketMessage = TicketMessage::create([ | ||||
| @@ -114,7 +114,7 @@ class TicketController extends Controller | ||||
|         $ticket->last_reply_user_id = $request->session()->get('id'); | ||||
|         if (!$ticketMessage || !$ticket->save()) { | ||||
|             DB::rollback(); | ||||
|             abort(500, __('user.ticket.reply.ticket_reply_failed')); | ||||
|             abort(500, __('Ticket reply failed')); | ||||
|         } | ||||
|         DB::commit(); | ||||
|         $this->sendNotify($ticket, $ticketMessage); | ||||
| @@ -127,17 +127,17 @@ class TicketController extends Controller | ||||
|     public function close(Request $request) | ||||
|     { | ||||
|         if (empty($request->input('id'))) { | ||||
|             abort(500, __('user.ticket.close.params_wrong')); | ||||
|             abort(500, __('Invalid parameter')); | ||||
|         } | ||||
|         $ticket = Ticket::where('id', $request->input('id')) | ||||
|             ->where('user_id', $request->session()->get('id')) | ||||
|             ->first(); | ||||
|         if (!$ticket) { | ||||
|             abort(500, __('user.ticket.close.ticket_not_exist')); | ||||
|             abort(500, __('Ticket does not exist')); | ||||
|         } | ||||
|         $ticket->status = 1; | ||||
|         if (!$ticket->save()) { | ||||
|             abort(500, __('user.ticket.close.close_failed')); | ||||
|             abort(500, __('Close failed')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => true | ||||
| @@ -163,15 +163,15 @@ class TicketController extends Controller | ||||
|                 Dict::WITHDRAW_METHOD_WHITELIST_DEFAULT | ||||
|             ) | ||||
|         )) { | ||||
|             abort(500, __('user.ticket.withdraw.not_support_withdraw_method')); | ||||
|             abort(500, __('Unsupported withdrawal method')); | ||||
|         } | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         $limit = config('v2board.commission_withdraw_limit', 100); | ||||
|         if ($limit > ($user->commission_balance / 100)) { | ||||
|             abort(500, __('user.ticket.withdraw.system_require_withdraw_limit', ['limit' => $limit])); | ||||
|             abort(500, __('The current required minimum withdrawal commission is', ['limit' => $limit])); | ||||
|         } | ||||
|         DB::beginTransaction(); | ||||
|         $subject = __('user.ticket.withdraw.ticket_subject'); | ||||
|         $subject = __('[Commission Withdrawal Request] This ticket is opened by the system'); | ||||
|         $ticket = Ticket::create([ | ||||
|             'subject' => $subject, | ||||
|             'level' => 2, | ||||
| @@ -180,12 +180,12 @@ class TicketController extends Controller | ||||
|         ]); | ||||
|         if (!$ticket) { | ||||
|             DB::rollback(); | ||||
|             abort(500, __('user.ticket.withdraw.ticket_create_failed')); | ||||
|             abort(500, __('Failed to open ticket')); | ||||
|         } | ||||
|         $message = __('user.ticket.withdraw.ticket_message', [ | ||||
|             'method' => $request->input('withdraw_method'), | ||||
|             'account' => $request->input('withdraw_account') | ||||
|         ]); | ||||
|         $message = sprintf("%s\r\n%s", | ||||
|             __('Withdrawal method') . ":" . $request->input('withdraw_method'), | ||||
|             __('Withdrawal account') . ":" . $request->input('withdraw_account') | ||||
|         ); | ||||
|         $ticketMessage = TicketMessage::create([ | ||||
|             'user_id' => $request->session()->get('id'), | ||||
|             'ticket_id' => $ticket->id, | ||||
| @@ -193,7 +193,7 @@ class TicketController extends Controller | ||||
|         ]); | ||||
|         if (!$ticketMessage) { | ||||
|             DB::rollback(); | ||||
|             abort(500, __('user.ticket.withdraw.ticket_create_failed')); | ||||
|             abort(500, __('Failed to open ticket')); | ||||
|         } | ||||
|         DB::commit(); | ||||
|         $this->sendNotify($ticket, $ticketMessage); | ||||
|   | ||||
| @@ -29,19 +29,19 @@ class UserController extends Controller | ||||
|     { | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         if (!$user) { | ||||
|             abort(500, __('user.user.changePassword.user_not_exist')); | ||||
|             abort(500, __('The user does not exist')); | ||||
|         } | ||||
|         if (!Helper::multiPasswordVerify( | ||||
|             $user->password_algo, | ||||
|             $request->input('old_password'), | ||||
|             $user->password) | ||||
|         ) { | ||||
|             abort(500, __('user.user.changePassword.old_password_wrong')); | ||||
|             abort(500, __('The old password is wrong')); | ||||
|         } | ||||
|         $user->password = password_hash($request->input('new_password'), PASSWORD_DEFAULT); | ||||
|         $user->password_algo = NULL; | ||||
|         if (!$user->save()) { | ||||
|             abort(500, __('user.user.changePassword.save_failed')); | ||||
|             abort(500, __('Save failed')); | ||||
|         } | ||||
|         $request->session()->flush(); | ||||
|         return response([ | ||||
| @@ -70,7 +70,7 @@ class UserController extends Controller | ||||
|             ]) | ||||
|             ->first(); | ||||
|         if (!$user) { | ||||
|             abort(500, __('user.user.info.user_not_exist')); | ||||
|             abort(500, __('The user does not exist')); | ||||
|         } | ||||
|         $user['avatar_url'] = 'https://cdn.v2ex.com/gravatar/' . md5($user->email) . '?s=64&d=identicon'; | ||||
|         return response([ | ||||
| @@ -110,12 +110,12 @@ class UserController extends Controller | ||||
|             ]) | ||||
|             ->first(); | ||||
|         if (!$user) { | ||||
|             abort(500, __('user.user.getSubscribe.user_not_exist')); | ||||
|             abort(500, __('The user does not exist')); | ||||
|         } | ||||
|         if ($user->plan_id) { | ||||
|             $user['plan'] = Plan::find($user->plan_id); | ||||
|             if (!$user['plan']) { | ||||
|                 abort(500, __('user.user.getSubscribe.plan_not_exist')); | ||||
|                 abort(500, __('Subscription plan does not exist')); | ||||
|             } | ||||
|         } | ||||
|         $user['subscribe_url'] = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token']; | ||||
| @@ -129,12 +129,12 @@ class UserController extends Controller | ||||
|     { | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         if (!$user) { | ||||
|             abort(500, __('user.user.resetSecurity.user_not_exist')); | ||||
|             abort(500, __('The user does not exist')); | ||||
|         } | ||||
|         $user->uuid = Helper::guid(true); | ||||
|         $user->token = Helper::guid(); | ||||
|         if (!$user->save()) { | ||||
|             abort(500, __('user.user.resetSecurity.reset_failed')); | ||||
|             abort(500, __('Reset failed')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user->token | ||||
| @@ -150,12 +150,12 @@ class UserController extends Controller | ||||
|  | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         if (!$user) { | ||||
|             abort(500, __('user.user.update.user_not_exist')); | ||||
|             abort(500, __('The user does not exist')); | ||||
|         } | ||||
|         try { | ||||
|             $user->update($updateData); | ||||
|         } catch (\Exception $e) { | ||||
|             abort(500, __('user.user.update.save_failed')); | ||||
|             abort(500, __('Save failed')); | ||||
|         } | ||||
|  | ||||
|         return response([ | ||||
| @@ -167,15 +167,15 @@ class UserController extends Controller | ||||
|     { | ||||
|         $user = User::find($request->session()->get('id')); | ||||
|         if (!$user) { | ||||
|             abort(500, __('user.user.transfer.user_not_exist')); | ||||
|             abort(500, __('The user does not exist')); | ||||
|         } | ||||
|         if ($request->input('transfer_amount') > $user->commission_balance) { | ||||
|             abort(500, __('user.user.transfer.insufficient_commission_balance')); | ||||
|             abort(500, __('Insufficient commission balance')); | ||||
|         } | ||||
|         $user->commission_balance = $user->commission_balance - $request->input('transfer_amount'); | ||||
|         $user->balance = $user->balance + $request->input('transfer_amount'); | ||||
|         if (!$user->save()) { | ||||
|             abort(500, __('user.user.transfer.transfer_failed')); | ||||
|             abort(500, __('Transfer failed')); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => true | ||||
|   | ||||
		Reference in New Issue
	
	Block a user