nuevo formulario
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CompatibilidadDgo extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'historial_id',
|
||||
'tipo_dispositivo',
|
||||
'marca_dispositivo',
|
||||
'ciudad',
|
||||
];
|
||||
|
||||
public function historial()
|
||||
{
|
||||
return $this->belongsTo(Historiale::class);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user