Update ShowServicios.php

This commit is contained in:
lizandrogd
2025-03-04 19:33:40 -05:00
parent 422452fd61
commit eedf2e9e2b
+13
View File
@@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Twilio\Rest\Client; use Twilio\Rest\Client;
use AshAllenDesign\ShortURL\Facades\ShortURL; use AshAllenDesign\ShortURL\Facades\ShortURL;
use Illuminate\Support\Facades\DB;
class ShowServicios extends Component class ShowServicios extends Component
{ {
@@ -239,6 +240,9 @@ class ShowServicios extends Component
/* ---------------- Btn Comprar ---------------- */ /* ---------------- Btn Comprar ---------------- */
public function comprar() public function comprar()
{ {
DB::beginTransaction();
try {
$this->validate([ $this->validate([
'cantidad_tarjetaPlan' => 'required|numeric|min:1', 'cantidad_tarjetaPlan' => 'required|numeric|min:1',
]); ]);
@@ -462,9 +466,18 @@ class ShowServicios extends Component
]); ]);
} }
DB::commit();
$this->tarjetaPlan = false; $this->tarjetaPlan = false;
$this->cantidad_tarjetaPlan = 1; $this->cantidad_tarjetaPlan = 1;
} catch (Exception $e) {
DB::rollBack();
$this->alert('error', 'Error al comprar: ' . $e->getMessage(), [
'position' => 'top'
]);
}
} }
public function credenciales($historial) public function credenciales($historial)