Delete

@param Transaction $model

@return \Illuminate\Http\JsonResponse
558965
public function delete(Transaction $model)
    {
        try {
            $model->delete();
        } catch(\Exception $e) {
            abort(409, 'Cannot delete record');
        }

        \Cache::tags('response')->flush();

        return $this->successJsonResponse();
    }
943656
public function delete($model, $id) {
		$runtime = $this->runtime[$model->alias];

		$data = array();
		$fields = $this->_normalizeFields($model);
		foreach ($fields as $flag => $date) {
			if (true === $runtime || $flag === $runtime) {
				$data[$flag] = true;
				if ($date) {
					$data[$date] = date('Y-m-d H:i:s');
				}
				if ($flag === $runtime) {
					break;
				}
			}
		}

		$record = $model->find('first', array(
			'fields' => $model->primaryKey,
			'conditions' => array($model->primaryKey => $id),
			'recursive' => -1
		));

		if (!empty($record)) {
			$model->set($model->primaryKey, $id);
			unset($model->data[$model->alias]['modified']);
			unset($model->data[$model->alias]['updated']);
			return $model->save(array($model->alias => $data), false, array_keys($data));
		}

		return true;
	}
1265626
public function delete(\Tx_Oelib_Model $model)
    {
        if ($this->isModelAMemoryOnlyDummy($model)) {
            throw new \InvalidArgumentException(
                'This model is a memory-only dummy that must not be deleted.',
                1331319817
            );
        }
        if ($model->isReadOnly()) {
            throw new \InvalidArgumentException('This model is read-only and must not be deleted.', 1331319836);
        }
        if ($model->isDead()) {
            return;
        }

        if ($model->hasUid()) {
            if (!$model->isLoaded()) {
                $this->load($model);
            }
            $model->setToDeleted();
            $this->save($model);
            $this->deleteOneToManyRelations($model);
        }
        $model->markAsDead();
    }
1307385
public function delete($pk = NULL)
    {
        $this->action = self::API_ACTION_DELETE;
        $this->closeTransaction(200);
        $deleted = FALSE;
        $message = null;
        if (NULL !== $pk) {
            try {
                $this->con->beginTransaction();
                $this->hydrateModel($pk);
                if (NULL !== $this->model) {
                    if(method_exists('clearAllReferences', $this->model)) {
                        $this->model->clearAllReferences(true);
                    }
                    $this->model->delete($this->con);
                    $deleted = TRUE;
                }
            } catch (\Exception $e) {
                $context = [];
                if(null !== $e->getPrevious()) {
                    $context[] = $e->getPrevious()->getMessage();
                }
                Logger::log($e->getMessage(), LOG_CRIT, $context);

            }
        }

        return $this->json(new JsonResponse(null, $deleted, $deleted, 0, $message), ($deleted) ? 200 : 400);
    }
715671
public function delete(Identifiable $model)
    {
        $model = $this->checkTypeAndReturn($model);
        $this->storage->offsetUnset($model->getId());
        return $this->persistIfNeeded();

    }
1271448
public function deleteSoft(HCResourceGrabPropertyRequest $request): JsonResponse
{
    $this->connection->beginTransaction();

    try {
        $this->service->getRepository()->deleteSoft($request->getListIds());

        $this->connection->commit();
    } catch (\Throwable $exception) {
        $this->connection->rollBack();

        return $this->response->error($exception->getMessage());
    }

    return $this->response->success('Successfully deleted');
}
138588
public function delete($model) {
        if ($model) {
            if (!is_array($model)) {
                $model = array($model);
            }
            return parent::delete($model);
        }
        else {
            return parent::delete();
        }
        return $this;
    }
276568
public function undelete($model, $id) {
		$runtime = $this->runtime[$model->alias];
		$this->softDelete($model, false);

		$data = array();
		$fields = $this->_normalizeFields($model);
		foreach ($fields as $flag => $date) {
			if (true === $runtime || $flag === $runtime) {
				$data[$flag] = false;
				if ($date) {
					$data[$date] = null;
				}
				if ($flag === $runtime) {
					break;
				}
			}
		}

		$model->create();
		$model->set($model->primaryKey, $id);
		$result = $model->save(array($model->alias => $data), false, array_keys($data));
		$this->softDelete($model, $runtime);
		return $result;
	}
627720
public function deleteModel($model)
    {
        // first remove any automatically created models
        /** @var $relationField ManyToManyField */
        foreach ($model->getMeta()->localManyToMany as $name => $relationField) {
            if ($relationField->relation->through->getMeta()->autoCreated) {
                $this->deleteModel($relationField->relation->through);
            }
        }
        $this->dropTable($model->getMeta()->getDbTable());
    }
1103741
public function doDelete($model, $id)
    {
        if ($this->weak) {
            return;
        }

        $delete = $this->dsql();
        if ($this->reverse) {
            $delete->where($this->foreign_field, $this->owner->id);
        } else {
            $delete->where($this->foreign_field, $this->owner[$this->master_field]);
        }

        $delete->delete()->execute();
    }
1227504
public function deleteModels(Models $models)
    {
        foreach ($models as $model) {
            $this->dispatchBeforeEvent($model, Event::DELETE);
        }

        $this->deleteAll()->executeModels($models);

        foreach ($models as $model) {
            $this->dispatchAfterEvent($model, Event::DELETE);
        }

        return $this;
    }
710545
public function delete(Storable $model, AbstractModel $parent = null)
    {
        $types = array('Invoice', 'Estimate', 'RecurringTemplate', 'IncomingInvoice');
        foreach ($types as $type) {
            $interface = $type . '\Subject';
            $method = 'get' . $type . 's';
            if (($model instanceof $interface) && count($model->$method($this->getService($type))) > 0) {
                throw new ForbiddenException('Unable to delete ' . $type . 'Subject with ' . strtolower($type) . 's');
            }
        }
        $this->request(
            $this->buildUrl($model, $parent), 'DELETE'
        );

        return $this;
    }
1129534
public function clearCache(Model $model) {
        if ($this->_cached) {
            foreach ($this->_cached as $key => $value) {
                $this->deleteCache($model, $key);
            }
        }

        return Cache::clear(false, $this->settings[$model->alias]['cacheConfig']);
    }
666932
private function doCommitDelete(Model $model)
    {
        $this->dispatchLifecycleEvent(Events::preDelete, $model);

        $this->getPersisterFor($model->getType())->delete($model);
        $model->getState()->setDeleted();

        $this->dispatchLifecycleEvent(Events::postDelete, $model);
        return $model;
    }
579147
public function deleting(Model $model)
    {
        $model->deleted_by = $this->guard->check() ? $this->guard->user()->getId() : null;
    }
409058
public function Delete($model)
    {
        $this->OpenTransaction();

        $primaryKey = ModelState::GetPrimary($model);
        $table = $this->getTableName($model);

        if($primaryKey != null) {
            $exec = $this->prepare("DELETE FROM " . $table . " WHERE " . $primaryKey . " = " . $model->$primaryKey . " LIMIT 1");
            $exec->execute();
            if($exec->rowCount() > 0)
                return true;

            throw new OwlException("A execução atingiu um numero 0 de linhas");
        }
        return false;
    }
532093
public function block($model)
    {
        $deletedAtLeastOne = false;

        if ($this->friends->count()) {
            foreach ($this->friends as $friend) {
                if ($friend->getKey() == $model->id) {
                    $friend->pivot->delete();
                    $this->resetFriends();

                    $deletedAtLeastOne = true;
                }
            }
        }

        return $deletedAtLeastOne;
    }