archivo de configuracion de nginx agregado para el puerto 9000
This commit is contained in:
@@ -2,9 +2,12 @@
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Docente;
|
||||
use App\Models\Entrega;
|
||||
use App\Models\Material;
|
||||
use App\Models\Tarea;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Component;
|
||||
|
||||
class GrupoDocente extends Component
|
||||
@@ -16,42 +19,45 @@ class GrupoDocente extends Component
|
||||
public $materia_id;
|
||||
public $materiasSelect;
|
||||
|
||||
public function mount($grupo)
|
||||
{
|
||||
$this->grupo = $grupo; // <- primero asignar el grupo
|
||||
// Para reemplazo de docente
|
||||
public $reemplazoDocenteActualId;
|
||||
public $reemplazoMateriaId;
|
||||
public $reemplazoDocenteId = '';
|
||||
public $reemplazoMateriaNombre = '';
|
||||
|
||||
$user = Auth::user();
|
||||
$plantelesIds = $user->plantelUsuarios->pluck('id');
|
||||
public function mount($grupo)
|
||||
{
|
||||
$this->grupo = $grupo;
|
||||
|
||||
$this->docentes = Docente::with(['docentes.plantelUsuarios'])
|
||||
->whereHas('docentes', function($query) use ($plantelesIds) {
|
||||
$query->whereHas('plantelUsuarios', function($q) use ($plantelesIds) {
|
||||
$q->whereIn('plantels.id', $plantelesIds);
|
||||
});
|
||||
$user = Auth::user();
|
||||
$plantelesIds = $user->plantelUsuarios->pluck('id');
|
||||
|
||||
$this->docentes = Docente::with(['docentes.plantelUsuarios'])
|
||||
->whereHas('docentes', function ($query) use ($plantelesIds) {
|
||||
$query->whereHas('plantelUsuarios', function ($q) use ($plantelesIds) {
|
||||
$q->whereIn('plantels.id', $plantelesIds);
|
||||
});
|
||||
})
|
||||
->get();
|
||||
|
||||
$this->materias = Material::whereHas('carreraMaterial', function ($query) use ($grupo) {
|
||||
$query->where('carreras.id', $grupo->plan->carrera);
|
||||
})
|
||||
->orderBy('ciclo')
|
||||
->get();
|
||||
|
||||
// Todas las materias de la carrera sin filtro de ciclo
|
||||
$this->materias = Material::whereHas('carreraMaterial', function($query) use ($grupo) {
|
||||
$query->where('carreras.id', $grupo->plan->carrera);
|
||||
})
|
||||
->orderBy('ciclo')
|
||||
->get();
|
||||
$materiasAsignadas = DB::table('docente_grupo')
|
||||
->where('grupo_id', $this->grupo->id)
|
||||
->pluck('materia_id')
|
||||
->toArray();
|
||||
|
||||
$materiasAsignadas = DB::table('docente_grupo')
|
||||
->where('grupo_id', $this->grupo->id)
|
||||
->pluck('materia_id')
|
||||
->toArray();
|
||||
|
||||
$this->materiasSelect = Material::whereHas('carreraMaterial', function($query) use ($grupo) {
|
||||
$query->where('carreras.id', $grupo->plan->carrera);
|
||||
})
|
||||
->where('ciclo', $this->grupo->ciclo) // solo ciclo actual
|
||||
->when(!empty($materiasAsignadas), function($query) use ($materiasAsignadas) {
|
||||
$query->whereNotIn('id', $materiasAsignadas); // excluir ya asignadas
|
||||
})
|
||||
->get();
|
||||
}
|
||||
$this->materiasSelect = Material::whereHas('carreraMaterial', function ($query) use ($grupo) {
|
||||
$query->where('carreras.id', $grupo->plan->carrera);
|
||||
})
|
||||
->where('ciclo', $this->grupo->ciclo)
|
||||
->when(!empty($materiasAsignadas), fn($q) => $q->whereNotIn('id', $materiasAsignadas))
|
||||
->get();
|
||||
}
|
||||
|
||||
public function guardar()
|
||||
{
|
||||
@@ -61,33 +67,79 @@ $this->materiasSelect = Material::whereHas('carreraMaterial', function($query) u
|
||||
]);
|
||||
|
||||
$this->grupo->docentes()->attach($this->docente_id, [
|
||||
'materia_id' => $this->materia_id
|
||||
'materia_id' => $this->materia_id,
|
||||
]);
|
||||
|
||||
$this->reset(['docente_id', 'materia_id']);
|
||||
$this->dispatch('close-modal-docente');
|
||||
|
||||
$this->dispatch('swal',
|
||||
icon: 'success',
|
||||
title: '¡Listo!',
|
||||
icon: 'success', title: '¡Listo!',
|
||||
text: 'Docente asignado correctamente',
|
||||
timer: 3000,
|
||||
confirm: false,
|
||||
closeModal: true,
|
||||
timer: 3000, confirm: false, closeModal: true,
|
||||
);
|
||||
}
|
||||
|
||||
public function eliminar($docenteId, $materiaId)
|
||||
{
|
||||
// Borrar archivos físicos de las entregas antes de eliminar en cascada
|
||||
$tareaIds = Tarea::where('grupo_id', $this->grupo->id)
|
||||
->where('material_id', $materiaId)
|
||||
->where('docente_id', $docenteId)
|
||||
->pluck('id');
|
||||
|
||||
Entrega::whereIn('tarea_id', $tareaIds)
|
||||
->whereNotNull('archivo')
|
||||
->pluck('archivo')
|
||||
->each(fn($path) => Storage::delete($path));
|
||||
|
||||
Tarea::whereIn('id', $tareaIds)->delete();
|
||||
|
||||
$this->grupo->docentes()->wherePivot('materia_id', $materiaId)->detach($docenteId);
|
||||
|
||||
$this->dispatch('swal',
|
||||
icon: 'success',
|
||||
title: 'Eliminado',
|
||||
text: 'Docente removido de la materia correctamente',
|
||||
timer: 2000,
|
||||
confirm: false,
|
||||
closeModal: true,
|
||||
icon: 'success', title: 'Eliminado',
|
||||
text: 'Docente y sus tareas removidos correctamente',
|
||||
timer: 2000, confirm: false, closeModal: true,
|
||||
);
|
||||
}
|
||||
|
||||
public function abrirReemplazo($docenteId, $materiaId, $materiaNombre)
|
||||
{
|
||||
$this->reemplazoDocenteActualId = $docenteId;
|
||||
$this->reemplazoMateriaId = $materiaId;
|
||||
$this->reemplazoMateriaNombre = $materiaNombre;
|
||||
$this->reemplazoDocenteId = '';
|
||||
$this->dispatch('open-modal-reemplazo');
|
||||
}
|
||||
|
||||
public function reemplazar()
|
||||
{
|
||||
$this->validate([
|
||||
'reemplazoDocenteId' => 'required|exists:docentes,id|different:reemplazoDocenteActualId',
|
||||
], [
|
||||
'reemplazoDocenteId.required' => 'Selecciona un docente.',
|
||||
'reemplazoDocenteId.different' => 'Debes elegir un docente diferente al actual.',
|
||||
]);
|
||||
|
||||
// Actualizar el registro en docente_grupo
|
||||
DB::table('docente_grupo')
|
||||
->where('grupo_id', $this->grupo->id)
|
||||
->where('materia_id', $this->reemplazoMateriaId)
|
||||
->where('docente_id', $this->reemplazoDocenteActualId)
|
||||
->update(['docente_id' => $this->reemplazoDocenteId]);
|
||||
|
||||
// Reasignar las tareas al nuevo docente (conserva entregas intactas)
|
||||
Tarea::where('grupo_id', $this->grupo->id)
|
||||
->where('material_id', $this->reemplazoMateriaId)
|
||||
->where('docente_id', $this->reemplazoDocenteActualId)
|
||||
->update(['docente_id' => $this->reemplazoDocenteId]);
|
||||
|
||||
$this->reset(['reemplazoDocenteId', 'reemplazoMateriaId', 'reemplazoDocenteActualId', 'reemplazoMateriaNombre']);
|
||||
$this->dispatch('close-modal-reemplazo');
|
||||
$this->dispatch('swal',
|
||||
icon: 'success', title: '¡Docente reemplazado!',
|
||||
text: 'El nuevo docente fue asignado y las tareas previas se conservaron.',
|
||||
timer: 3500, confirm: false, closeModal: true,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user