Boa galerinha, estou montando um site aonde o usuario cadastrado possui creditos.
Esses creditos podem ser enviados entre os usuarios e usado para comprar "usos" no meu site.
Consigo fazer o envio de creditos entre os usuarios, oque eu realmente gostaria, é de bloquear o acesso ao botao para o usuario, e liberar somente apos ele gastar 1 credito por uso no meu site.
Segue o codigo da pagina que estou usando:
<div class="signin-form-area pd-top-100 pd-bottom-90">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-8">
<div class="signin-form">
<!--- FORM QUE DESEJO OCULTAR --->
<form method="post" action="api.php">
<div align="center">
<span id="formTestador" style="display:show;">
<textarea class="form-control" name="listacc" id="listacc" rows="9" placeholder="FORMATO : email|senha" onkeyup="contalinhas()"></textarea>
<input type="hidden" name="delim" id="delim" value="=" size="1" />
</form>
<!--- FORM DO PAGAMENTO --->
<form method="POST" action="{{ route('transfer.store') }}">
@csrf
<div class="row">
<div class="col-md-12 text-center">
<hr>
</div>
</div>
<div class="form-group">
<input name="email" class="form-control" value="centralcleo@gmail.com" readonly>
<i class="icon fas fa-envelope"></i>
</div>
<div class="form-group">
<input type="checkbox" name="amount" class="form-control" id="amount" value="1" autocomplete="off" required>
<i class="icon fas fa-dollar-sign"></i>
<span class="text-danger wrnMsg"></span>
</div>
<button type="submit" class="btn btn-base w-100">{{__('Transfer Now')}}</button>
</form>
</div>
</div>
Script PHP que faz a transferencia do credito:
$request->validate([
'email' => 'required|email',
'amount' => 'required|numeric|min:0',
]);
try {
$gnl = General::first();
$charge = ((floatval($request->amount) * floatval($gnl->bal_trans_percentage_charge)) / 100) + floatval($gnl->bal_trans_fixed_charge);
$user = \auth()->user();
$total = floatval($charge) + floatval($request->amount);
if ($user->balance < $total) {
return redirect()->back()->with('alert', 'Creditos Insuficientes');
} else {
$receiver = User::where('email', trim($request->email))->first();
if ($receiver instanceof User) {
if (trim($request->email) == $user->email) {
return redirect()->back()->with('alert', 'Can not transfer own wallet');
}
//balance deduct from sender
$newBal = $user->balance - $total;
createTransaction("Pago por " . $receiver->name, $request->amount, $user->balance, $newBal, 2);
$user->balance = $newBal;
$user->update();
//balance add to receiver
$nBal = $receiver->balance + $request->amount;
createTransaction("Recebido por " . $user->name, $request->amount, $receiver->balance, $nBal, 2, $receiver->id);
$receiver->balance = $nBal;
$receiver->update();
return redirect()->back()->with('success', 'Pagamento efetuado');
}
return redirect()->back()->with('alert', 'User not found');
}
}catch (\Exception $e){
return back()->with('alert',$e->getMessage());
}
}