Example #1
0
 public function delete($id)
 {
     if ($this->find($id)) {
         return $this->tableGateway->delete(['id' => (int) $id]);
     }
     return false;
 }
 public function find($id)
 {
     $resultSet = $this->tableGateway->select(['id' => (int) $id]);
     if ($resultSet->count() == 1) {
         return $resultSet->current();
     }
     return FALSE;
 }
 /**
  * Delete one resouce
  */
 public function delete($id)
 {
     if (!$id) {
         return new ApiProblem(415, "Unsupported Media Type");
     }
     $this->tableGateway->delete(['id' => (int) $id]);
     return true;
 }
Example #4
0
 public function findBy(array $columns)
 {
     $result = $this->tableGateway->select($columns);
     if (!$result->current()) {
         throw new \Exception('Entity not found.', 404);
     }
     return $result;
 }
Example #5
0
 public function save(Motivo $motivo)
 {
     $data = $motivo->toArray();
     if (empty($motivo->codigo)) {
         $this->tableGateway->insert($data);
     } else {
         $this->tableGateway->update('codigo=' . $motivo->codigo);
     }
 }
 public function delete($id)
 {
     $existe = $this->tableGateway->select(['id' => (int) $id]);
     if (count($existe) === 1) {
         $this->tableGateway->delete(['id' => (int) $id]);
         $existe = $this->tableGateway->select(['id' => (int) $id]);
         if (count($existe) === 1) {
             return new ApiProblem(450, 'Não foi possivel excluir o registro', null, 'Problemas ao excluir');
         }
         return true;
     }
     return new ApiProblem(451, 'O registro não foi encontrado na base de dados', null, 'Registro não encontrado');
 }
 /**
  * Fetch an existing resource.
  *
  * @param int|string $id Identifier of resource.
  * @return array|object Resource.
  * @throws DomainException if the resource is not found.
  */
 public function fetch($id)
 {
     $resultSet = $this->table->select([$this->identifierName => $id]);
     if (0 === $resultSet->count()) {
         throw new DomainException('Item not found', 404);
     }
     return $resultSet->current();
 }
 public function deleteItem($id)
 {
     //Eu tinha feito delete on cascade no banco anteriormente. Por isso não tinha implementado esse metodo aqui.
     $result = $this->orderItemTableGateway->delete(['order_id' => (int) $id]);
     return $result;
 }
 public function findByUsername($username)
 {
     return $this->tableGateway->select(['username' => $username])->current();
 }
 public function delete($id)
 {
     $this->tableGateway->delete(['id' => (int) $id]);
 }
 public function delete($id)
 {
     $deletar = $this->tableGateway->delete(['id' => (int) $id]);
     return $deletar;
 }
Example #12
0
 public function updateItem($id, array $data)
 {
     $this->itemTable->update($data, ['id' => (int) $id]);
     return $this->itemTable->select(['id' => (int) $id])->current();
 }
 public function update($id, $data)
 {
     $mapper = new UsersMapper();
     return $this->tableGateway->update($mapper->extract($data), ['id' => $id]);
 }
 public function find($id)
 {
     $resultSet = $this->tableGateway->select(['id' => (int) $id]);
     return $resultSet->current();
 }