Good evening, gentlemen, I am here to inform you that I am able to make the 100% cashout part work:
core/routes/web.php:
<?php
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\User\WithdrawController;
Route::get('/clear', function () {
\Illuminate\Support\Facades\Artisan::call('optimize:clear');
});
Route::get('cron', 'CronController@cron')->name('cron');
// User Support Ticket
Route::controller('TicketController')->prefix('ticket')->name('ticket.')->group(function () {
Route::get('/', 'supportTicket')->name('index');
Route::get('new', 'openSupportTicket')->name('open');
Route:
ost('create', 'storeSupportTicket')->name('store');
Route::get('view/{ticket}', 'viewTicket')->name('view');
Route:
ost('reply/{ticket}', 'replyTicket')->name('reply');
Route:
ost('close/{ticket}', 'closeTicket')->name('close');
Route::get('download/{ticket}', 'ticketDownload')->name('download');
});
Route::get('/user/withdraw/history', [WithdrawController::class, 'withdrawLog'])->name('user.withdraw.history');
Route::get('/user/withdraw', [WithdrawController::class, 'withdrawMoney'])->name('user.withdraw');
Route:
ost('/user/withdraw/submit', [WithdrawController::class, 'withdrawSubmit'])->name('user.withdraw.submit');
Route::get('/user/withdraw/preview', [WithdrawController::class, 'withdrawPreview'])->name('user.withdraw.preview');
Route::get('user/withdraw/withdraw-method', [WithdrawController::class, 'withdrawMethod'])->name('withdraw.method');
Route:
ost('user/withdraw/withdraw-request/confirm', [WithdrawController::class, 'withdrawSubmit'])->name('withdraw.submit');
Route:
ost('/user/withdraw/withdraw-request', [WithdrawController::class, 'withdrawStore'])->name('user.withdraw.money');
Route::get('app/deposit/confirm/{hash}', 'Gateway\PaymentController@appDepositConfirm')->name('deposit.app.confirm');
Route::controller('SiteController')->group(function () {
Route:
ost('/request/coin', 'requestCoin')->name('request.coin')->middleware('auth');
Route::get('/contact', 'contact')->name('contact');
Route:
ost('/contact', 'contactSubmit');
Route::get('/change/{lang?}', 'changeLanguage')->name('lang');
Route::get('cookie-policy', 'cookiePolicy')->name('cookie.policy');
Route::get('/cookie/accept', 'cookieAccept')->name('cookie.accept');
Route::get('blog/{slug}/{id}', 'blogDetails')->name('blog.details');
Route::get('policy/{slug}/{id}', 'policyPages')->name('policy.pages');
Route::get('placeholder-image/{size}', 'placeholderImage')->name('placeholder.image');
Route::get('lottery-ticket', 'getSingleTicket')->name('lottery.ticket.single');
Route::get('lottery-tickets', 'lotteryTickets')->name('lottery.tickets');
Route::get('{slug}/{id}/play', 'playLottery')->name('lottery.play');
Route::get('results', 'results')->name('results');
Route::get('blogs', 'blogs')->name('blogs');
Route::get('faqs', 'faqs')->name('faqs');
Route::get('/{slug}', 'pages')->name('pages');
Route::get('/', 'index')->name('home');
});
-------------------------------------------------- ------------------------------------------------------------------------
core/app/Http/Controllers/User/WithdrawController.php
<?php
namespace App\Http\Controllers\User;
use App\Constants\Status;
use App\Http\Controllers\Controller;
use App\Lib\FormProcessor;
use App\Models\AdminNotification;
use App\Models\Transaction;
use App\Models\Withdrawal;
use App\Models\WithdrawMethod;
use Illuminate\Http\Request;
class WithdrawController extends Controller
{
public function withdrawMoney()
{
$withdrawMethod = WithdrawMethod::where('status',Status::ENABLE)->get();
$pageTitle = 'Withdraw Money';
return view($this->activeTemplate.'user.withdraw.methods', compact('pageTitle','withdrawMethod'));
}
public function withdrawStore(Request $request)
{
$this->validate($request, [
'method_code' => 'required',
'amount' => 'required|numeric'
]);
$method = WithdrawMethod::where('id', $request->method_code)->where('status', Status::ENABLE)->firstOrFail();
$user = auth()->user();
if ($request->amount < $method->min_limit) {
$notify[] = ['error', 'Your requested amount is smaller than minimum amount.'];
return back()->withNotify($notify);
}
if ($request->amount > $method->max_limit) {
$notify[] = ['error', 'Your requested amount is larger than maximum amount.'];
return back()->withNotify($notify);
}
if ($request->amount > $user->balance) {
$notify[] = ['error', 'You do not have sufficient balance for withdraw.'];
return back()->withNotify($notify);
}
$charge = $method->fixed_charge + ($request->amount * $method->percent_charge / 100);
$afterCharge = $request->amount - $charge;
$finalAmount = $afterCharge * $method->rate;
$withdraw = new Withdrawal();
$withdraw->method_id = $method->id; // wallet method ID
$withdraw->user_id = $user->id;
$withdraw->amount = $request->amount;
$withdraw->currency = $method->currency;
$withdraw->rate = $method->rate;
$withdraw->charge = $charge;
$withdraw->final_amount = $finalAmount;
$withdraw->after_charge = $afterCharge;
$withdraw->trx = getTrx();
$withdraw->save();
session()->put('wtrx', $withdraw->trx);
return to_route('user.withdraw.preview');
}
public function withdrawPreview()
{
$withdraw = Withdrawal::with('method','user')->where('trx', session()->get('wtrx'))->where('status', Status:
AYMENT_INITIATE)->orderBy('id','desc')->firstOrFail();
$pageTitle = 'Withdraw Preview';
return view($this->activeTemplate . 'user.withdraw.preview', compact('pageTitle','withdraw'));
}
public function withdrawSubmit(Request $request)
{
$withdraw = Withdrawal::with('method','user')->where('trx', session()->get('wtrx'))->where('status', Status:
AYMENT_INITIATE)->orderBy('id','desc')->firstOrFail();
$method = $withdraw->method;
if ($method->status == Status:
ISABLE) {
abort(404);
}
$formData = $method->form->form_data;
$formProcessor = new FormProcessor();
$validationRule = $formProcessor->valueValidation($formData);
$request->validate($validationRule);
$userData = $formProcessor->processFormData($request, $formData);
$user = auth()->user();
if ($user->ts) {
$response = verifyG2fa($user,$request->authenticator_code);
if (!$response) {
$notify[] = ['error', 'Wrong verification code'];
return back()->withNotify($notify);
}
}
if ($withdraw->amount > $user->balance) {
$notify[] = ['error', 'Your request amount is larger then your current balance.'];
return back()->withNotify($notify);
}
$withdraw->status = Status:
AYMENT_PENDING;
$withdraw->withdraw_information = $userData;
$withdraw->save();
$user->balance -= $withdraw->amount;
$user->save();
$transaction = new Transaction();
$transaction->user_id = $withdraw->user_id;
$transaction->amount = $withdraw->amount;
$transaction->post_balance = $user->balance;
$transaction->charge = $withdraw->charge;
$transaction->trx_type = '-';
$transaction->details = showAmount($withdraw->final_amount) . ' ' . $withdraw->currency . ' Withdraw Via ' . $withdraw->method->name;
$transaction->trx = $withdraw->trx;
$transaction->remark = 'withdraw';
$transaction->save();
$adminNotification = new AdminNotification();
$adminNotification->user_id = $user->id;
$adminNotification->title = 'New withdraw request from '.$user->username;
$adminNotification->click_url = urlPath('admin.withdraw.details',$withdraw->id);
$adminNotification->save();
notify($user, 'WITHDRAW_REQUEST', [
'method_name' => $withdraw->method->name,
'method_currency' => $withdraw->currency,
'method_amount' => showAmount($withdraw->final_amount),
'amount' => showAmount($withdraw->amount),
'charge' => showAmount($withdraw->charge),
'rate' => showAmount($withdraw->rate),
'trx' => $withdraw->trx,
'post_balance' => showAmount($user->balance),
]);
$notify[] = ['success', 'Withdraw request sent successfully'];
return to_route('user.withdraw.history')->withNotify($notify);
}
public function withdrawLog(Request $request)
{
$pageTitle = "Withdraw Log";
$withdraws = Withdrawal::where('user_id', auth()->id())->where('status', '!=', Status:
AYMENT_INITIATE);
if ($request->search) {
$withdraws = $withdraws->where('trx',$request->search);
}
$withdraws = $withdraws->with('method')->orderBy('id','desc')->paginate(getPaginate());
return view($this->activeTemplate.'user.withdraw.log', compact('pageTitle','withdraws'));
}
}
---------------------------------------------------------------------------------------------------------------------------
gentlemen, good use everyone, I'm glad I was able to help you