From 0282645c0805d21fef9e20d966673614196a2253 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 18 Jun 2026 11:06:49 -0500 Subject: [PATCH] nuevo formulario --- app/Http/Livewire/ShowServicio.php | 7 +- app/Http/Livewire/ShowServicios.php | 29 +++++ app/Models/CompatibilidadDgo.php | 23 ++++ app/Models/Historiale.php | 5 + app/Models/Servicio.php | 9 +- ...6_18_000001_add_dgo_to_servicios_table.php | 22 ++++ ...00002_create_compatibilidad_dgos_table.php | 25 +++++ .../views/livewire/show-servicio.blade.php | 14 +++ .../views/livewire/show-servicios.blade.php | 100 ++++++++++++++++++ 9 files changed, 231 insertions(+), 3 deletions(-) create mode 100644 app/Models/CompatibilidadDgo.php create mode 100644 database/migrations/2026_06_18_000001_add_dgo_to_servicios_table.php create mode 100644 database/migrations/2026_06_18_000002_create_compatibilidad_dgos_table.php diff --git a/app/Http/Livewire/ShowServicio.php b/app/Http/Livewire/ShowServicio.php index dde9e81..1b81de4 100755 --- a/app/Http/Livewire/ShowServicio.php +++ b/app/Http/Livewire/ShowServicio.php @@ -38,6 +38,7 @@ class ShowServicio extends Component public $url; public $precio; public $renovacion = false; + public $dgo = false; protected $rules = [ 'nombre_servicio' => 'required', @@ -110,6 +111,7 @@ class ShowServicio extends Component $servicio->url = $this->url; $servicio->renovacion = $this->renovacion; $servicio->precio = $this->precio; + $servicio->dgo = $this->dgo; $servicio->save(); $this->alert('success', 'Servicio creado correctamente!', [ @@ -141,6 +143,7 @@ class ShowServicio extends Component $this->url = $consulta_servicios->url; $this->renovacion = $consulta_servicios->renovacion == 1 ? true : false; $this->precio = $consulta_servicios->precio; + $this->dgo = $consulta_servicios->dgo == 1 ? true : false; } public function guardar() { @@ -200,7 +203,8 @@ class ShowServicio extends Component 'ver_url' => $this->ver_url, 'url' => $this->url, 'renovacion' => $this->renovacion == 1 ? true : false, - 'precio'=> $this->precio + 'precio'=> $this->precio, + 'dgo' => $this->dgo ]); $this->serviciosEditar = false; @@ -270,6 +274,7 @@ class ShowServicio extends Component $this->completa = null; $this->tiempo = null; $this->renovacion = null; + $this->dgo = null; $this->servicio = null; } } diff --git a/app/Http/Livewire/ShowServicios.php b/app/Http/Livewire/ShowServicios.php index bfebf61..961e430 100755 --- a/app/Http/Livewire/ShowServicios.php +++ b/app/Http/Livewire/ShowServicios.php @@ -12,6 +12,7 @@ use App\Models\Log_general; use App\Models\Promociones; use App\Models\Saldo; use App\Models\Servicio; +use App\Models\CompatibilidadDgo; use App\Models\Tarifas; use App\Models\User; use App\Models\Usuario_tarifa; @@ -65,6 +66,10 @@ class ShowServicios extends Component public $utilidad; public $tp = false; public $usuario_actual; + public $dgo = false; + public $tipo_dispositivo; + public $marca_dispositivo; + public $ciudad; use LivewireAlert; protected $rules = [ @@ -156,6 +161,7 @@ class ShowServicios extends Component $this->valor_tarjetaPlan = ($usuario_tarifa) ? $usuario_tarifa->precio : $tarifa_seleccionada->valor; //Si tiene tarifa personalizada toma la utilidad, si no tiene toma la utilidad de la tarifa. $this->utilidad = ($usuario_tarifa) ? $usuario_tarifa->utilidad : $tarifa_seleccionada->utilidad; + $this->dgo = $servicio_tarifa->dgo == 1 ? true : false; //Fecha de vencimiento del servicio. $this->fechaFinal = $this->fechaActual->addDay($tarifa_seleccionada->dias); @@ -223,6 +229,9 @@ class ShowServicios extends Component $this->cantidad_tarjetaPlan = 1; $this->tarjetaPlan = false; $this->tarifa_id = ''; + $this->tipo_dispositivo = null; + $this->marca_dispositivo = null; + $this->ciudad = null; } public function notificacionPocas($servicio, $restantes) @@ -269,6 +278,14 @@ class ShowServicios extends Component return; } + if ($this->dgo) { + $this->validate([ + 'tipo_dispositivo' => 'required', + 'marca_dispositivo' => 'required', + 'ciudad' => 'required', + ]); + } + $cantidad_solicitada = (int) $this->cantidad_tarjetaPlan * (int) $this->pantallas_tarjetaPlan; $total_valor = (int) $this->valor_tarjetaPlan * (int) $this->cantidad_tarjetaPlan; $utilidad_total = (int) $this->utilidad * (int) $this->cantidad_tarjetaPlan; @@ -575,10 +592,22 @@ class ShowServicios extends Component } + if ($this->dgo) { + CompatibilidadDgo::create([ + 'historial_id' => $historial->id, + 'tipo_dispositivo' => $this->tipo_dispositivo, + 'marca_dispositivo' => $this->marca_dispositivo, + 'ciudad' => $this->ciudad, + ]); + } + DB::commit(); $this->tarjetaPlan = false; $this->cantidad_tarjetaPlan = 1; + $this->tipo_dispositivo = null; + $this->marca_dispositivo = null; + $this->ciudad = null; // si todo salió bien → salir del bucle break; diff --git a/app/Models/CompatibilidadDgo.php b/app/Models/CompatibilidadDgo.php new file mode 100644 index 0000000..b0850e1 --- /dev/null +++ b/app/Models/CompatibilidadDgo.php @@ -0,0 +1,23 @@ +belongsTo(Historiale::class); + } +} diff --git a/app/Models/Historiale.php b/app/Models/Historiale.php index 6319259..72b063d 100755 --- a/app/Models/Historiale.php +++ b/app/Models/Historiale.php @@ -52,4 +52,9 @@ class Historiale extends Model { return $this->belongsToMany(Cuentas::class, 'logs', 'historial_id', 'cuenta_id'); } + + public function compatibilidadDgo() + { + return $this->hasOne(CompatibilidadDgo::class); + } } diff --git a/app/Models/Servicio.php b/app/Models/Servicio.php index 621f2af..f179b0b 100755 --- a/app/Models/Servicio.php +++ b/app/Models/Servicio.php @@ -26,8 +26,8 @@ class Servicio extends Model 'por_tiempo', 'renovacion', 'precio', - 'ubicacion' - + 'ubicacion', + 'dgo', ]; public function promocion(){ @@ -41,4 +41,9 @@ class Servicio extends Model public function cuentas(){ return $this ->hasMany(Cuentas::class,'servicio_id'); } + + public function compatibilidadDgo() + { + return $this->hasMany(CompatibilidadDgo::class); + } } diff --git a/database/migrations/2026_06_18_000001_add_dgo_to_servicios_table.php b/database/migrations/2026_06_18_000001_add_dgo_to_servicios_table.php new file mode 100644 index 0000000..438214b --- /dev/null +++ b/database/migrations/2026_06_18_000001_add_dgo_to_servicios_table.php @@ -0,0 +1,22 @@ +boolean('dgo')->default(false); + }); + } + + public function down() + { + Schema::table('servicios', function (Blueprint $table) { + $table->dropColumn('dgo'); + }); + } +}; diff --git a/database/migrations/2026_06_18_000002_create_compatibilidad_dgos_table.php b/database/migrations/2026_06_18_000002_create_compatibilidad_dgos_table.php new file mode 100644 index 0000000..f66f51e --- /dev/null +++ b/database/migrations/2026_06_18_000002_create_compatibilidad_dgos_table.php @@ -0,0 +1,25 @@ +id(); + $table->foreignId('historial_id')->constrained()->onDelete('cascade'); + $table->string('tipo_dispositivo'); + $table->string('marca_dispositivo'); + $table->string('ciudad'); + $table->timestamps(); + }); + } + + public function down() + { + Schema::dropIfExists('compatibilidad_dgos'); + } +}; diff --git a/resources/views/livewire/show-servicio.blade.php b/resources/views/livewire/show-servicio.blade.php index 8c51afd..7f67728 100755 --- a/resources/views/livewire/show-servicio.blade.php +++ b/resources/views/livewire/show-servicio.blade.php @@ -88,6 +88,7 @@
Compatibilidad DGO
+Identifica desde qué dispositivo accederás
+ +@@ -436,6 +527,15 @@ {!! $msj->msj_compra !!}
Compatibilidad DGO
+Tipo: {{ $cuentas->compatibilidadDgo->tipo_dispositivo }}
+Marca: {{ $cuentas->compatibilidadDgo->marca_dispositivo }}
+Ciudad: {{ $cuentas->compatibilidadDgo->ciudad }}
+Información de cuentas: