public function delete($id)
 {
     $tableGateway = $this->repository->getTableGateway();
     try {
         $tableGateway->getAdapter()->getDriver()->getConnection()->beginTransaction();
         $order = $tableGateway->select(['id' => (int) $id]);
         if ($order) {
             $this->repository->deleteItem($id);
             $deletaOrder = $this->repository->delete($id);
         }
         $tableGateway->getAdapter()->getDriver()->getConnection()->commit();
         return $deletaOrder;
     } catch (\Exception $e) {
         $tableGateway->getAdapter()->getDriver()->getConnection()->rollback();
         return 'error';
     }
 }
 public function delete($id)
 {
     try {
         $this->repository->beginTransaction();
         $this->repository->deleteItems($id);
         $this->repository->delete($id);
         $this->repository->commitTransaction();
         return true;
     } catch (Exception $e) {
         $this->repository->rollbackTransaction();
         return false;
     }
 }
Beispiel #3
0
 public function delete($id)
 {
     try {
         $order = $this->ordersRepository->find($id);
         $itemTable = $this->ordersRepository->getItemTable();
         $items = $itemTable->select(['order_id' => $order->getId()]);
         foreach ($items as $item) {
             $itemTable->delete(['id' => $item->getId()]);
         }
         return $this->ordersRepository->delete($order->getId());
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage());
     }
 }
 /**
  * Delete a resource
  *
  * @param  mixed $id
  * @return ApiProblem|mixed
  */
 public function delete($id)
 {
     return (bool) $this->ordersRepository->delete($id);
 }