芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/tblonline.org/app/Http/Controllers/WithdrawRequestController.php
with('user') ->with('method') ->with('method.currency') ->orderBy("withdraw_requests.id", "desc"); return Datatables::eloquent($withdraw_requests) ->filter(function ($query) use ($request) { $status = $request->has('status') ? $request->status : 1; $query->where('status', $status); }, true) ->editColumn('user.name', function ($withdraw_request) { return '
' . $withdraw_request->user->name . '
' . $withdraw_request->user->email; }) ->editColumn('amount', function ($withdraw_request) { return decimalPlace($withdraw_request->amount, currency($withdraw_request->method->currency->name)); }) ->editColumn('status', function ($withdraw_request) { return transaction_status($withdraw_request->status); }) ->addColumn('action', function ($withdraw_request) { $actions = '
'; $actions .= '
' . _lang('Details') . '
'; $actions .= $withdraw_request->status != 2 ? '
' . _lang('Approve') . '
' : ''; $actions .= $withdraw_request->status != 0 ? '
' . _lang('Reject') . '
' : ''; $actions .= csrf_field(); $actions .= '
'; $actions .= '
' . _lang('Delete') . '
'; $actions .= '
'; return $actions; }) ->setRowId(function ($withdraw_request) { return "row_" . $withdraw_request->id; }) ->rawColumns(['user.name', 'status', 'action']) ->make(true); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(Request $request, $id) { $withdrawRequest = WithdrawRequest::find($id); if (!$request->ajax()) { return back(); } else { return view('backend.withdraw_request.modal.view', compact('withdrawRequest', 'id')); } } /** * Approve Wire Transfer * * @param int $id * @return \Illuminate\Http\Response */ public function approve($id) { DB::beginTransaction(); $withdrawRequest = WithdrawRequest::find($id); $withdrawRequest->status = 2; $withdrawRequest->save(); $transaction = Transaction::find($withdrawRequest->transaction_id); $transaction->status = 2; $transaction->save(); try { $transaction->user->notify(new ApprovedWithdrawRequest($transaction)); } catch (\Exception $e) {} DB::commit(); return redirect()->route('withdraw_requests.index')->with('success', _lang('Request Approved')); } /** * Reject Wire Transfer * * @param int $id * @return \Illuminate\Http\Response */ public function reject($id) { DB::beginTransaction(); $withdrawRequest = WithdrawRequest::find($id); $transaction = Transaction::find($withdrawRequest->transaction_id); $transaction->status = 0; $transaction->save(); $withdrawRequest->status = 0; $withdrawRequest->save(); try { $transaction->user->notify(new RejectWithdrawRequest($transaction)); } catch (\Exception $e) {} DB::commit(); return redirect()->route('withdraw_requests.index')->with('success', _lang('Request Rejected')); } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $withdrawRequest = WithdrawRequest::find($id); if ($withdrawRequest->transaction_id != null) { $transaction = Transaction::find($withdrawRequest->transaction_id); $transaction->delete(); } $withdrawRequest->delete(); return redirect()->route('deposit_requests.index')->with('success', _lang('Deleted Successfully')); } }