Esempio n. 1
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');
     }
 }