reclamar premio
This commit is contained in:
@@ -3,13 +3,18 @@
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Notificacion;
|
||||
use App\Models\Saldo;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Livewire\Component;
|
||||
use Jantinnerezo\LivewireAlert\LivewireAlert;
|
||||
|
||||
class Bell extends Component
|
||||
{
|
||||
use LivewireAlert;
|
||||
|
||||
public $numNoti = 0;
|
||||
public $menuNotificaciones = false;
|
||||
public $reclamandoPremio = false;
|
||||
|
||||
public function render()
|
||||
{
|
||||
@@ -35,4 +40,32 @@ class Bell extends Component
|
||||
$notificacion->update(['estado' => false]);
|
||||
}
|
||||
}
|
||||
|
||||
public function reclamarPremio($id)
|
||||
{
|
||||
if ($this->reclamandoPremio) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->reclamandoPremio = true;
|
||||
|
||||
$notificacion = Notificacion::find($id);
|
||||
|
||||
$consulta_saldo = Saldo::where('usuario_id', Auth::user()->id)->first();
|
||||
|
||||
if ($consulta_saldo) {
|
||||
$consulta_saldo->update([
|
||||
'valor' => $consulta_saldo->valor + $notificacion->premio
|
||||
]);
|
||||
if ($notificacion) {
|
||||
$notificacion->update(['estado' => false]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->reclamandoPremio = false;
|
||||
|
||||
$this->alert('success', 'Haz reclamado el premio correctamente', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ class ShowUsuarios extends Component
|
||||
|
||||
$recarga = new recarga;
|
||||
$recarga->payment_method_id = 'manual';
|
||||
$recarga->status = 'Aprovada';
|
||||
$recarga->status = 'approved';
|
||||
$recarga->usuario_id = $this->user_saldo;
|
||||
$recarga->saldo_id = $this->consulta_saldo->id;
|
||||
$recarga->monto = $this->valor_recargar;
|
||||
|
||||
Reference in New Issue
Block a user