/** * Añade un profesor en un instituto como lider del mismo. * * @param int $id * @return \Symfony\Component\HttpFoundation\Response */ public function createLeadFromInstituteToProfessor($id) { $professors = []; $institute = Institute::findOrFail($id); Professor::all()->load('personalDetails')->each(function (Professor $professor) use(&$professors) { $surname = $professor->personalDetails->first_surname; $name = $professor->personalDetails->first_name; $ci = $professor->personalDetails->ci; $data = "{$surname}, {$name}. {$ci}"; $professors[$professor->id] = $data; }); if (!$professors) { Flash::error('No hay Profesores disponibles para asignar'); return Redirect::back(); } return View::make('institutesProfessors.forms.createLeadFromInstToProf', compact('institute', 'professors')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($semester = null, $year = null) { $user = Auth::user(); $split = explode(" ", $user->role->name); $role_area = $split[count($split) - 1]; $areas = Area::with('professors')->get()->toArray(); $profe = Professor::with('areas')->get()->toArray(); $prof_areas = array(); foreach ($profe as $prof) { $prof_areas[$prof['id']] = $prof['areas']; } $collection = collect($areas); $area_professors = $collection->keyBy('name')->toArray(); // TODO: Pasar esto a un Helper if ($semester == null) { \Carbon\Carbon::now()->month >= 5 ? $semester = 2 : ($semester = 1); } $year == null ? $year = \Carbon\Carbon::now()->year : ($year = $year); $courses = Course::with('area')->get()->toArray(); if ($role_area == "Administrador") { $professors = Professor::all()->toArray(); //TODO: Pasar esto a un scope $unasigned_courses = Course::with('area')->where('taken', 0)->where('semester', $semester)->where('year', $year)->get(); $asigned_courses = Course::with('area')->where('taken', 1)->where('semester', $semester)->where('year', $year)->get(); } else { $professors = Area::with('professors')->where('name', $role_area)->get()->toArray()[0]["professors"]; $area = Area::where('name', $role_area)->first(); $unasigned_courses = Course::where('taken', 0)->where('area_id', $area->id)->where('semester', $semester)->where('year', $year)->get(); $asigned_courses = Course::where('taken', 1)->where('area_id', $area->id)->where('semester', $semester)->where('year', $year)->get(); } $professorCourse = array(); foreach ($courses as $course) { if (Schedule::where('course_id', $course['id'])->first() != null) { $professorId = Schedule::where('course_id', $course['id'])->first()->professor_id; $professorCourse[$course['id']] = Professor::where('id', $professorId)->first()->name; } } return view('schedules.index', compact('area_professors', 'prof_areas', 'professors', 'courses', 'professorCourse', 'unasigned_courses', 'asigned_courses', 'year', 'semester')); }
/** * Display a listing of the resource. * * @return \Symfony\Component\HttpFoundation\Response */ public function index() { $professors = Professor::all(); return View::make('professors.index', compact('professors')); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $agendaEdit = $this->agendamentos->find($id); if (is_null($agendaEdit)) { return redirect()->route('agendamentos.index'); } $agendaEdit['predio'] = DB::table('salas')->where('id', $agendaEdit->sala_id)->value('predio'); $predios = DB::table('salas')->distinct()->lists('predio', 'predio'); $salas = Sala::all()->lists('numero', 'id'); $profs = Professor::all()->lists('nome', 'id'); $agendaEdit->dia = $this->formatDate($agendaEdit->dia, 'd/m/Y'); //retorna apenas os 5 primeiros caracteres //original 14:30:00 => retorna 14:30 $agendaEdit->hora_inicio = substr($agendaEdit->hora_inicio, 0, 5); $agendaEdit->hora_fim = substr($agendaEdit->hora_fim, 0, 5); $horas = $this->getHours(); return view('agendamentos.edit', compact('agendaEdit', 'horas', 'predios', 'salas', 'profs')); }