/**
  * Update the specified resource in storage.
  *
  * @param \App\Http\Requests\PersonalDetailsRequest $request
  * @param  int $id
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function update(PersonalDetailsRequest $request, $id)
 {
     $details = PersonalDetail::findOrFail($id)->load('user');
     $details->update($request->all());
     Flash::success('Datos personales actualizados correctamente.');
     return Redirect::route('users.show', $details->user->name);
 }
Ejemplo n.º 2
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);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param int $id
  * @param \App\Http\Requests\ProfessorRequest $request
  * @param \App\Professor $professor
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function store($id, ProfessorRequest $request, Professor $professor)
 {
     /** @var PersonalDetail $details */
     $details = PersonalDetail::findOrFail($id);
     if (Gate::denies('createProfessor', $details)) {
         Flash::error('Ud. no tiene permisos para esta acción.');
         return Redirect::back();
     }
     $professor->title_id = $request->input('title_id');
     $details->professor()->save($professor);
     return Redirect::route('users.show', $details->user_id);
 }
Ejemplo n.º 4
0
 /**
  * Genera un pdf de certificado de participante
  *
  * @param int $attendantId
  * @param int $eventId
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function showPdf($attendantId, $eventId)
 {
     /** @var PersonalDetail $attendant */
     $attendant = PersonalDetail::findOrFail($attendantId);
     if (!Auth::user()->isOwnerOrAdmin($attendant->user_id)) {
         Flash::error('Ud. no tiene permisos para esta acción.');
         return Redirect::back();
     }
     $event = $attendant->events()->where('id', $eventId)->first();
     if (!$event->pivot->approved) {
         Flash::error('Este Participante no esta aprobado para estar en este evento.');
         return Redirect::back();
     }
     $attendants = collect()->push($attendant);
     $pdf = App::make('dompdf.wrapper');
     $pdf->loadView('events.pdf.CUFM', compact('attendants', 'event'));
     $pdf->setOrientation('landscape');
     return $pdf->stream();
 }