update
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Cuentas;
|
||||
use App\Models\Historiale;
|
||||
use App\Models\Historial_cuenta;
|
||||
use App\Models\Log_general;
|
||||
use App\Models\Pendientes;
|
||||
use App\Models\Role;
|
||||
use App\Models\Servicio;
|
||||
use App\Models\Tarifas;
|
||||
@@ -119,7 +120,6 @@ class ShowPlanes extends Component
|
||||
->where('servicio_id', $this->servicio_modTarifas)
|
||||
->where('estado', 'activo')
|
||||
->get();
|
||||
|
||||
}
|
||||
|
||||
// Empezamos definiendo la consulta básica
|
||||
@@ -222,14 +222,15 @@ class ShowPlanes extends Component
|
||||
/* ------------- CREAR ------------- */
|
||||
public function createNewCuenta()
|
||||
{
|
||||
$this->validate([
|
||||
'servicio_newCuenta' => 'required',
|
||||
'usuario_newCuenta' => 'required',
|
||||
'password_newCuenta' => 'required',
|
||||
'fecha_inicial' => 'required',
|
||||
'fecha_final' => 'required',
|
||||
'estado' => 'required',
|
||||
]);
|
||||
// $this->validate([
|
||||
// 'servicio_newCuenta' => 'required',
|
||||
// 'usuario_newCuenta' => 'required',
|
||||
// 'password_newCuenta' => 'required',
|
||||
// 'fecha_inicial' => 'required',
|
||||
// 'fecha_final' => 'required',
|
||||
// 'estado' => 'required',
|
||||
// ]);
|
||||
|
||||
|
||||
|
||||
if ($consulta_cuenta = Cuentas::where('correo', $this->usuario_newCuenta)->exists()) {
|
||||
@@ -246,6 +247,21 @@ class ShowPlanes extends Component
|
||||
$cuenta->estado = $this->estado;
|
||||
$cuenta->save();
|
||||
|
||||
if ($this->estado === 'activo') {
|
||||
$servicioPantallas = Servicio::find($this->servicio_newCuenta)->pantallas;
|
||||
|
||||
$cuentasPendientes = Pendientes::where('estado', 'pendiente')->where('servicio_id', $this->servicio_newCuenta)->take($servicioPantallas)->get();
|
||||
|
||||
foreach ($cuentasPendientes as $i => $cuentaPendiente) {
|
||||
$historial_cuenta = new Historial_cuenta();
|
||||
$historial_cuenta->historial_id = $cuentaPendiente->historial_id;
|
||||
$historial_cuenta->cuenta_id = $cuenta->id;
|
||||
$historial_cuenta->perfil = $i + 1;
|
||||
$historial_cuenta->save();
|
||||
$cuentaPendiente->update(['estado' => 'cerrado']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->alert('success', 'Cuenta creada correctamente!', [
|
||||
'position' => 'top'
|
||||
]);
|
||||
@@ -254,8 +270,6 @@ class ShowPlanes extends Component
|
||||
|
||||
$this->newCuenta = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function createServicio()
|
||||
{
|
||||
@@ -390,8 +404,6 @@ class ShowPlanes extends Component
|
||||
'position' => 'top'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -434,19 +446,19 @@ class ShowPlanes extends Component
|
||||
$this->color_servicio = null;
|
||||
}
|
||||
|
||||
public function eliminarCuentas(){
|
||||
public function eliminarCuentas()
|
||||
{
|
||||
|
||||
$consulta_cuentas = Cuentas::whereIn('id', $this->delete_1)->delete();
|
||||
|
||||
}
|
||||
|
||||
public function openAdd(){
|
||||
public function openAdd()
|
||||
{
|
||||
|
||||
$this->addUser = true;
|
||||
|
||||
|
||||
}
|
||||
public function saveUser(){
|
||||
public function saveUser()
|
||||
{
|
||||
|
||||
$this->validate([
|
||||
'tarifa' => 'required',
|
||||
@@ -500,17 +512,16 @@ class ShowPlanes extends Component
|
||||
|
||||
$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'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function editar($tarifa){
|
||||
public function editar($tarifa)
|
||||
{
|
||||
//dd($tarifa);
|
||||
$this->editarTarifaRol = true;
|
||||
$this->informacionTarifaRol = $tarifa;
|
||||
@@ -524,7 +535,8 @@ class ShowPlanes extends Component
|
||||
$this->servicio_modTarifas = $tarifa['servicio_id'];
|
||||
}
|
||||
|
||||
public function actualizarTarifaRol($id){
|
||||
public function actualizarTarifaRol($id)
|
||||
{
|
||||
//dd($id);
|
||||
$validateData = $this->validate([
|
||||
'roles_modTarifas' => 'required',
|
||||
@@ -549,6 +561,5 @@ class ShowPlanes extends Component
|
||||
]);
|
||||
|
||||
$this->editarTarifaRol = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user