MINI MINI MANI MO
<?php
namespace App\Http\Controllers;
use App\Models\asistenciaVotos;
use App\Models\Comisiones;
use App\Models\ComisionUsuario;
use App\Models\DatosUsers;
use App\Models\EventoVotos;
use App\Models\mensajesVotos;
use App\Models\temasVotos;
use Illuminate\Http\Request;
class ComController extends Controller
{
private $request;
public function __construct(Request $request) {
$this->request=$request;
// $this->middleware('auth');
}
public function index()
{
$eventoActivo = EventoVotos::where('estatus', 1)->get();
if (count($eventoActivo)) {
$comision = Comisiones::where('random', $eventoActivo[0]->tipoEventoIntegrantes)->get();
// dd($comision);
if ($comision[0]->random != 'jo7uWqChe') {
$parlamentarioComision = ComisionUsuario::where('id_commission', $comision[0]->id)->get();
// dd($parlamentarioComision);
foreach ($parlamentarioComision as $comisionUs) {
$comisiones[] = Commission::find($comisionUs->id_commission);
}
$temaVotos = temasVotos::where('status', 1)->get();
$votacion = mensajesVotos::where('status', 1)->get();
$favor = 0;
$contra = 0;
$abstencion = 0;
$totalVotos = 0;
$totalAsistencias = 0;
foreach ($votacion as $voto) {
if ($voto->mensaje == 'FAVOR') {
$favor = $favor + 1;
} elseif ($voto->mensaje == 'CONTRA') {
$contra = $contra + 1;
} elseif ($voto->mensaje == 'ABSTENCION') {
$abstencion = $abstencion + 1;
}
$totalVotos = $favor + $contra + $abstencion;
}
$asistencias = asistenciaVotos::where('status', 1)->where('randomEvento', $eventoActivo[0]->random)->get();
foreach ($asistencias as $asiste) {
if ($asiste->mensaje == 'ASISTENCIA') {
$totalAsistencias = $totalAsistencias + 1;
}
}
$turnos = Turnos::where('status', 1)->where('randomEvento', $eventoActivo[0]->random)->orderBy('created_at', 'ASC')->get();
foreach ($comisiones as $comision) {
if ($comision->random == $eventoActivo[0]->tipoEvento) {
// dd('if');
return view("sistemaVotos.proyeccion", compact('eventoActivo', 'votacion', 'favor', 'contra', 'abstencion', 'totalVotos', 'asistencias', 'totalAsistencias', 'temaVotos', 'turnos'));
} else {
// dd('else');
// dd("no hay sesion activa");
return view("sistemaVotos.index");
}
}
}else{
$parlamentarioComision = DatosUsers::where('status',1)->get();
// dd($parlamentarioComision);
$temaVotos = temasVotos::where('status', 1)->get();
$votacion = mensajesVotos::where('status', 1)->get();
$favor = 0;
$contra = 0;
$abstencion = 0;
$totalVotos = 0;
$totalAsistencias = 0;
$asistencias = asistenciaVotos::where('status', 1)->where('randomEvento', $eventoActivo[0]->random)->get();
// $turnos = Turnos::where('status', 1)->where('randomEvento', $eventoActivo[0]->random)->orderBy('created_at', 'ASC')->get();
foreach ($votacion as $voto) {
if ($voto->mensaje == 'FAVOR') {
$favor = $favor + 1;
} elseif ($voto->mensaje == 'CONTRA') {
$contra = $contra + 1;
} elseif ($voto->mensaje == 'ABSTENCION') {
$abstencion = $abstencion + 1;
}
$totalVotos = $favor + $contra + $abstencion;
}
return view("sistemaVotos.proyeccionCom", compact('eventoActivo', 'votacion', 'favor', 'contra', 'abstencion', 'totalVotos', 'asistencias', 'totalAsistencias', 'temaVotos'));
// dd('ghjkis' );
}
}else{
// dd('else22');
return view("sistemaVotos.index");
}
}
public function validaEventosActivos2Com(){
$eventoActivo = EventoVotos::where('estatus', 1)->get();
$votacion = mensajesVotos::where('status',1)->get();
$asistencias = asistenciaVotos::where('status',1)->where('randomEvento',$eventoActivo[0]->random)->get();
$asistencias = count($asistencias);
$votacion = count($votacion);
$response[] = array(
"asistencias"=>$asistencias,
"votacion"=>$votacion,
);
return json_encode($response);
}
}
OHA YOOOO