promociones validadas

This commit is contained in:
Felipe
2024-01-17 17:25:49 -05:00
parent 88124183a4
commit 92a930cf0c
2 changed files with 21 additions and 8 deletions
+15 -2
View File
@@ -104,7 +104,7 @@ class ShowPromociones extends Component
'nombre_comprarPromo' => 'required',
'celular_comprarPromo' => 'required',
'email_comprarPromo' => 'required',
'cantidad_comprarPromo' => 'required',
'cantidad_comprarPromo' => 'required|numeric|min:1',
];
public function render()
@@ -207,9 +207,22 @@ class ShowPromociones extends Component
public function pagar()
{
$this->validate();
if ($this->cantidad_comprarPromo == 0){
$this->alert('error', 'La cantidad debe ser mayor a 0', [
'position' => 'top'
]);
return;
}
if (auth()->user()->saldo->valor < $this->precioAhora * $this->cantidad_comprarPromo) {
$this->alert('error', 'Saldo insuficiente', [
'position' => 'top'
]);
return;
}
$usuario_existe = User::firstWhere('email', $this->email_comprarPromo)->id ?? null;
if (is_null($usuario_existe)) {