listado de tarifas
This commit is contained in:
@@ -472,6 +472,10 @@ class ShowPlanes extends Component
|
||||
|
||||
|
||||
$tarifa = json_decode($this->tarifa, true);
|
||||
|
||||
|
||||
// dd($tarifa)
|
||||
|
||||
//dd($this->tarifa['dias']);
|
||||
$usuario_existe = User::firstWhere('email', $this->searchTerm)->id ?? null;
|
||||
$usuario_id = $usuario_existe;
|
||||
@@ -484,11 +488,12 @@ class ShowPlanes extends Component
|
||||
$usuario->password = '123456';
|
||||
$usuario->celular = '+57';
|
||||
$usuario->rol_id = $rol_id;
|
||||
$usuario->save();
|
||||
// $usuario->save();
|
||||
|
||||
$usuario_id = $usuario->id;
|
||||
}
|
||||
|
||||
dd($this->tarifa);
|
||||
|
||||
$historial = new Historiale;
|
||||
$historial->fecha_inicio = Carbon::now();
|
||||
@@ -500,28 +505,59 @@ class ShowPlanes extends Component
|
||||
$historial->tarifa_id = $tarifa['id'];
|
||||
$historial->cliente_id = $usuario_id;
|
||||
$historial->cantidad = $tarifa['pantallas'];
|
||||
$historial->save();
|
||||
// $historial->save();
|
||||
|
||||
$consultaHC = Historial_cuenta::where('cuenta_id', $this->consulta_verUsuarios->id)->where('perfil', $this->perfil)->exists();
|
||||
|
||||
if (!$consultaHC) {
|
||||
if ($this->consulta_verUsuarios->estado == 'pendiente') { // completa
|
||||
$perfiles = $this->consulta_verUsuarios->servicio->completa;
|
||||
}
|
||||
|
||||
if ($this->consulta_verUsuarios->estado == 'activo') { // pantallas
|
||||
$perfiles = $this->consulta_verUsuarios->servicio->pantallas;
|
||||
}
|
||||
|
||||
|
||||
dd($this->consulta_verUsuarios);
|
||||
|
||||
|
||||
|
||||
$consultaHC = Historial_cuenta::where('cuenta_id', $this->consulta_verUsuarios->id)->orderBy('created_at', 'desc')->first()->perfil ?? 0;
|
||||
|
||||
if ($consultaHC) {
|
||||
if ($consultaHC < 5) {
|
||||
$historial_cuenta = new Historial_cuenta;
|
||||
$historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id;
|
||||
$historial_cuenta->historial_id = $historial->id;
|
||||
$historial_cuenta->perfil = $consultaHC + 1;
|
||||
// $historial_cuenta->save();
|
||||
|
||||
$this->alert('success', 'Usuario añadido correctamente!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
|
||||
$this->addUser = false;
|
||||
$this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first();
|
||||
}else{
|
||||
$historial->delete();
|
||||
$this->alert('warning', 'Ya haz alcanzado el maximo de perfiles!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$historial_cuenta = new Historial_cuenta;
|
||||
$historial_cuenta->cuenta_id = $this->consulta_verUsuarios->id;
|
||||
$historial_cuenta->historial_id = $historial->id;
|
||||
$historial_cuenta->perfil = $this->perfil;
|
||||
$historial_cuenta->save();
|
||||
|
||||
$historial_cuenta->perfil = $consultaHC + 1;
|
||||
// $historial_cuenta->save();
|
||||
|
||||
$this->alert('success', 'Usuario añadido correctamente!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
|
||||
|
||||
$this->addUser = false;
|
||||
$this->consulta_verUsuarios = Cuentas::with('historiales', 'servicio')->where('id', $this->id_cuentaVer)->first();
|
||||
} else {
|
||||
$historial->delete();
|
||||
$this->alert('warning', 'El perfil ya se encuentra en uso!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user