dispatch('open-grupo-modal'); } public function mount($grupo) { $this->grupo = $grupo; } public function guardar() { if (empty($this->selectedAlumnos)) { session()->flash('error', 'Selecciona al menos un alumno'); return; } $this->grupo->alumnos()->syncWithoutDetaching($this->selectedAlumnos); $this->reset('selectedAlumnos'); $this->dispatch('swal', icon: 'success', title: 'Anexado!', text: 'Se agrego el alumno correctamente', timer: 2000, confirm: false, closeModal: true, reload: 2000 ); $this->dispatch('close-modal'); } public function render() { $user = Auth::user(); $grupo = $this->grupo; $plantelesUsuario = $user->plantelUsuarios->pluck('id'); $alumnos = Alumno::query() ->with(['alumnos.plantelUsuarios', 'statusAlumno', 'plan.carreraRel','nivelRel']) ->where('status', 2) ->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(); return view('livewire.grupo-alumno', [ 'alumnos' => $alumnos, ]); } }