Ejemplo n.º 1
0
 /**
  * @param                 $user_id
  * @param UserEditRequest $request
  *
  * @return mixed
  */
 public function editUser($user_id, UserEditRequest $request)
 {
     if ($user = User::find($user_id)) {
         $user->update($request->all());
         return $this->respondSuccess('User was successfully updated', ['user' => Fractal::item($user, new UserTransformer())->getArray()]);
     }
     throw new NotFoundHttpException();
 }
Ejemplo n.º 2
0
 /**
  * @param         $message_id
  * @param Request $request
  *
  * @return mixed
  * @throws NotFoundException
  */
 public function changeSubject($message_id, Request $request)
 {
     $this->validate($request, ['subject' => 'required']);
     if ($message = Message::find($message_id)) {
         $message->update($request->get('subject'));
         return $this->respondSuccess('Subject successfully updated', ['message' => Fractal::item($message, new MessageTransformer())]);
     }
     throw new NotFoundException();
 }
Ejemplo n.º 3
0
 public function show($id)
 {
     try {
         $user = User::find($id)->with('role')->firstOrFail();
         if ($user) {
             return Fractal::item($user, new \App\Transformers\UserTransformer())->responseJson(200);
         } else {
             return $this->respondNotFound();
         }
     } catch (Exception $e) {
         return $e;
     }
 }