Guardar cambios consolidar grupos docentes y clave de grupo

This commit is contained in:
2026-04-24 18:33:37 -06:00
parent 2d73e8a2b0
commit 2b072f7d55
10 changed files with 205 additions and 125 deletions
+13 -24
View File
@@ -57,32 +57,21 @@ class GrupoAlumno extends Component
$plantelesUsuario = $user->plantelUsuarios->pluck('id');
$alumnos = Alumno::query()
->with(['alumnos.plantelUsuarios', 'statusAlumno', 'plan.carreraRel','nivelRel'])
->with(['usuario', 'statusAlumno', 'plan.carreraRel', 'nivelRel'])
->where('status', 2)
// ✅ Cambia el 2 por el status correcto
->whereIn('status', [2, 3]) // inscrito o alumno
->where('nivel', $grupo->nivel)
->whereDoesntHave('grupos')
->whereHas('alumnos.plantelUsuarios', function ($q) use ($plantelesUsuario) {
$q->whereIn('plantels.id', $plantelesUsuario);
})
->orderByRaw("
CASE
WHEN plan_id = {$grupo->plan_id} THEN 0
ELSE 1
END
")
->orderByRaw("
CASE
WHEN nivel = {$grupo->nivel} THEN 0
ELSE 1
END"
)
->get();
->where('nivel', $grupo->nivel)
->whereDoesntHave('grupos')
->whereHas('usuario', function ($q) use ($plantelesUsuario) {
$q->whereHas('plantelUsuarios', function ($q2) use ($plantelesUsuario) {
$q2->whereIn('plantel_user.plantel_id', $plantelesUsuario);
});
})
->orderByRaw("CASE WHEN plan_id = {$grupo->plan_id} THEN 0 ELSE 1 END")
->orderByRaw("CASE WHEN nivel = {$grupo->nivel} THEN 0 ELSE 1 END")
->get();
return view('livewire.grupo-alumno', [
'alumnos' => $alumnos,
+6 -8
View File
@@ -71,25 +71,23 @@ $this->materiasSelect = Material::whereHas('carreraMaterial', function($query) u
icon: 'success',
title: '¡Listo!',
text: 'Docente asignado correctamente',
timer: 2000,
timer: 3000,
confirm: false,
closeModal: true,
reload: true
);
}
public function eliminar($docenteId)
public function eliminar($docenteId, $materiaId)
{
$this->grupo->docentes()->detach($docenteId);
$this->grupo->docentes()->wherePivot('materia_id', $materiaId)->detach($docenteId);
$this->dispatch('swal',
icon: 'success',
title: '¡Eliminado!',
text: 'Docente removido correctamente',
title: 'Eliminado',
text: 'Docente removido de la materia correctamente',
timer: 2000,
confirm: false,
closeModal: false,
reload: true
closeModal: true,
);
}