예제 #1
0
 /**
  * Store a newly created report.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     if ($request['professor']['lattes']->isValid()) {
         $professor = new Professor($request['professor']);
         $professor->makeReport();
         return Redirect::action('ReportsController@show')->with('professor', $professor);
     }
 }
예제 #2
0
 protected static function boot()
 {
     // TODO send email with randomly generated password
     Professor::created(function ($professor) {
         $professor->university->user()->create(['name' => $professor->first_name . ' ' . $professor->last_name, 'email' => $professor->email, 'password' => bcrypt('1234'), 'role' => 'professor']);
     });
 }
예제 #3
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     /** @var PersonalDetail $details */
     if ($this->method == 'POST') {
         $details = PersonalDetail::findOrFail($this->route('personalDetailsID'));
     } elseif ($this->method() == 'PUT' || $this->method() == 'PATCH') {
         $details = Professor::findOrFail($this->route('id'))->load('personalDetails');
     }
     return $this->user()->isOwnerOrAdmin($details->user_id);
 }
예제 #4
0
 /**
  * Genera el formulario para insertar profesores al evento.
  *
  * @param int $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function createProfessors($id)
 {
     /** @var Event $event */
     $event = Event::findOrFail($id);
     $professors = [];
     $existing = $event->professors()->pluck('id');
     Professor::whereNotIn('id', $existing)->with('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('events.forms.createProfessors', compact('event', 'professors'));
 }
예제 #5
0
 protected function create_professor(array $data)
 {
     return Professor::create(['prof_firstname' => $data['firstname'], 'prof_lastname' => $data['lastname'], 'prof_description' => $data['about'], 'prof_image' => $data['image'], 'inst_id' => $data['inst_id'], 'user_id' => $data['user_id']]);
 }
예제 #6
0
 public function import(Request $request)
 {
     $file = $request->file('excel');
     //var_dump($filename);
     Excel::load($file, function ($input) {
         $results = $input->all();
         foreach ($results as $result) {
             // Search if a course exist
             $professor = Professor::where('rut', $result->rut)->first();
             // if doesn't exist we save it
             if (!isset($professor)) {
                 $professor = new Professor();
                 $professor->name = $result->nombre_completo;
                 $professor->type = $result->categoria;
                 $professor->rut = $result->rut;
                 $professor->sede_origen = $result->sede_origen;
                 $professor->min_load = $result->carga_docente_minima;
                 $professor->max_load = $result->carga_docente_maxima;
                 $professor->save();
                 //TODO: Pasar esto a el modelo o a una query class
                 $areas = explode(',', $result->areas);
                 foreach ($areas as $key => $area) {
                     $areaIdArray[] = Area::where('name', $area)->first()->id;
                 }
                 $professor->areas()->sync($areaIdArray);
             }
         }
     });
     return redirect()->route('professors.index')->with('message', 'Cursos creados Correctamente.');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function destroy($id)
 {
     /** @var Professor $professor */
     $professor = Professor::findOrFail($id);
     $user = $professor->personalDetails->user;
     $this->destroyPrototype($professor, 'delete', 'Profesor');
     return Redirect::route('users.show', $user->id);
 }
 public function decline_prof(Request $request)
 {
     $user = User::find($request->input('prof_id'));
     $institution = Professor::where('user_id', $user['id']);
     $user->delete();
     $institution->delete();
     return redirect('institution/professors-pending');
 }
 /**
  * Guarda un profesor en un instituto.
  *
  * @param int $id
  * @param \App\Http\Requests\InstituteLeadForProfessorRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function storeInstituteForProfessor($id, InstituteLeadForProfessorRequest $request)
 {
     /** @var Professor $professor */
     $professor = Professor::findOrFail($id);
     $input = $request->input('institutes');
     $position = ucfirst($request->input('position'));
     $this->insertProfessorFromSelf($professor, $input, $position, false);
     Flash::success('Profesor asignado correctamente.');
     return Redirect::route('professors.show', $professor->id);
 }
예제 #10
0
 public function destroy(Request $request)
 {
     Professor::findOrFail($request->input('id'))->delete();
     return response('Deleted professor.', 200);
 }
예제 #11
0
 /**
  * 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'));
 }
예제 #12
0
 public function edit_profile(Request $request)
 {
     if ($request->image) {
         $professor = Professor::where('user_id', '=', \Auth::user()->id)->first();
         $imageName = "prof_" . $professor->id . '.' . Input::file('image')->getClientOriginalExtension();
         Input::file('image')->move(base_path() . '/public/images/professor/', $imageName);
         $professor->prof_image = $imageName . "";
         $professor->save();
         $professor->update(['firstname' => $request->firstname, 'lastname' => $request->lastname, 'description' => $request->description, 'image' => $imageName]);
         return redirect('/professor')->with('status', 'Profile Updated!');
     } else {
         $professor = Professor::where('user_id', '=', \Auth::user()->id)->first();
         $professor->update(['firstname' => $request->firstname, 'lastname' => $request->lastname, 'description' => $request->description]);
         return redirect('/professor')->with('status', 'Profile Updated!');
     }
 }
예제 #13
0
 public function insert_control(Request $request)
 {
     $professor = Professor::where('id', $request->get('professor'))->first();
     $area = $request->get('area');
     $period = $request->get('period');
     //dd($period);
     $insert_control = Insert_control::where('period', $period)->first();
     if ($insert_control != null) {
         $record = $insert_control;
         $record->available = !$record->available;
         $record->save();
     } else {
         $record = new Insert_control();
         $record->period = $period;
         $record->available = 1;
         $record->save();
     }
     return redirect("schedules/{$period}/{$area}/{$professor->id}");
 }