/**
  * 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);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $professor = Professor::findOrFail($id);
     $professor->delete();
     return redirect()->route('professors.index')->with('message', 'Item deleted successfully.');
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 public function destroy(Request $request)
 {
     Professor::findOrFail($request->input('id'))->delete();
     return response('Deleted professor.', 200);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, $area, $professor)
 {
     $course = Course::where('id', $id)->first();
     $course = Course::findOrFail($id);
     $course->taken = 0;
     $course->save();
     $prof = Professor::findOrFail($professor);
     $selectedCourseSchedule = explode("-", $course->schedule);
     $professorLoad = $prof->current_load - count($selectedCourseSchedule) * 22.5;
     $prof->current_load = $professorLoad;
     $prof->save();
     $schedules = schedule::where('course_id', $id)->delete();
     return redirect("schedules/{$course->year}-{$course->semester}/{$area}/{$professor}");
 }