示例#1
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function show($id)
 {
     $user = User::findOrFail($id, array('id', 'first_name', 'middle_name', 'last_name', 'email', 'phone'));
     return Response::json($user);
 }
示例#2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function edit($id)
 {
     $user = User::findOrFail($id, array('id', 'first_name', 'middle_name', 'last_name', 'email', 'phone'));
     $fields = array('last_name' => 'Фамилия', 'first_name' => 'Имя', 'middle_name' => 'Отчество', 'email' => 'Электронная почта', 'password' => 'Пароль', 'password_confirmation' => 'Подтверждение пароля');
     return Response::json(array('user' => $user, 'edit_fields' => $fields));
 }
示例#3
0
 /**
  * Удаление пользователя из БД.
  *
  * @param  int $id
  *
  * @throws \ErrorException
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function destroy($id)
 {
     $this->user = User::findOrFail($id);
     $activeConnection = $this->user->getConnection();
     $activeConnection->beginTransaction();
     try {
         $this->deleteUser();
         $activeConnection->commit();
     } catch (\Exception $error) {
         $activeConnection->rollBack();
         throw new \ErrorException('Failed to delete user');
     }
 }