Delete record with a specified id. If no ID is specified
then current record is deleted.

@param mixed $id

@throws Exception

@return $this
164583
public function delete($id = null)
    {
        if ($this->read_only) {
            throw new Exception(['Model is read-only and cannot be deleted']);
        }

        if ($id == $this->id) {
            $id = null;
        }

        return $this->atomic(function () use ($id) {
            if ($id) {
                $c = clone $this;
                $c->load($id)->delete();

                return $this;
            } elseif ($this->loaded()) {
                if ($this->hook('beforeDelete', [$this->id]) === false) {
                    return $this;
                }
                $this->persistence->delete($this, $this->id);
                $this->hook('afterDelete', [$this->id]);
                $this->unload();

                return $this;
            } else {
                throw new Exception(['No active record is set, unable to delete.']);
            }
        });
    }
341431
public function uncomplete($id)
    {
        $id = (int) $id;
        if ($id <= 0) {
            throw new Exception('Invalid param id');
        }
        return $this->rest->put("$this->action/$id/uncomplete");
    }
1011846
public function delete($id) {

		$bean = \R::findOne( $this->type, ' id = :id ', [ ':id' => $id ] );
		if ( !$bean ) {
			throw new \Exception('This '.$this->type.' does not exist.');
		}

		// Check for property type specific delete methods
		foreach ( $this->properties as $property ) {

			// Check if specific delete property method exists
			$c = new $property['type'];
			if ( method_exists( $c, 'delete' ) ) {
				$c->delete( $bean, $property );
			}

		}

		\R::trash( $bean );

	}
398943
public static function remove($id)
    {
        $s = new static();

        if (is_int($id)) {
            $where = "id = {$id}";
            self::$db->delete($s::$entity_table, $where);
        } else {
            throw new IDShouldBeNumber('Pass in an ID as the parameter, ID has to be a number', 1);
        }
    }
754741
public function delete($id = null)
    {
        // If an ID is passed to the method, we will set the where clause to check
        // the ID to allow developers to simply and quickly remove a single row
        // from their database without manually specifying the where clauses.
        if (!is_null($id)) {
            $this->where('id', '=', $id);
        }
        $this->compileWheres();

        return $this->query->delete()->run();
    }
475921
protected function deleteRequest($id)
    {
        $query = "DELETE FROM {$this->config->table_requests} WHERE id = :id";
        $query_prepared = $this->dbh->prepare($query);
        return $query_prepared->execute(['id' => $id]);
    }
508790
public function setDatatableId($id)
    {
        if (!array_key_exists($id, self::$instances)) {
            self::$instances[$id] = $this;
        } else {
            throw new \Exception('Identifer already exists');
        }

        return $this;
    }
796587
public function deleteByID($id) {
        $result = $this->api->request(
            'monitoring.livestatus.delete',
            [
                'id' => $id
            ]
        );

        if (!array_key_exists('success', $result) ||
            $result['success'] !== true) {
            if (array_key_exists('message', $result)) {
                throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
            } else {
                throw new RuntimeException('Bad result');
            }
        }

        return $this;
    }
209624
public function delete($id = null) {
		$this->Cliente->id = $id;
		if (!$this->Cliente->exists()) {
			throw new NotFoundException(__('Invalid %s', Configure::read('Mesa.tituloCliente')));
		}
		$this->request->allowMethod('post', 'delete');
		if ($this->Cliente->delete()) {
			$this->Session->setFlash(__('The %s has been deleted.', Configure::read('Mesa.tituloCliente')));
		} else {
			$this->Session->setFlash(__('The %s could not be deleted. Please, try again.', Configure::read('Mesa.tituloCliente')));
		}
		return $this->redirect(array('action' => 'index'));
	}
49752
public static function destroy($id) 
    {
        try {
            $file = self::find($id);
            
            if($file->descendants()->exists()) {
                foreach($file->descendants()->where('type', '!=', 'folder')->get() as $descendant) {
                    
                    event(new FileWasDeleted([ // fire 'file deleted' event for each descendant
                        'file' => $descendant
                    ]));
                }
            }
            
            $file->delete($id);

            if($file->type != 'folder') {
                event(new FileWasDeleted([ // fire 'file deleted' event for file
                    'file' => $file
                ]));
            }
        }
        
        catch (Exception $e) {
            throw $e;
        }
    }
785466
public function deleteRecords($id)
    {
        if (is_array($id)) {
            $params['idlist'] = implode(';', $id);
        } else {
            $params['id'] = $id;
        }

        return $this->call('deleteRecords', $params);
    }
661901
public function delete($id)
	{
		try {
			$this->getIndex()->deleteObject($id);
		} catch (\Exception $e) {
			return false;
		}
		
		return true;
	}
325700
public function delete($id)
    {
        $query = $this->createQueryBuilder();

        $query->where($this->getPrimaryKey($query), $id);
        $query->delete();
    }
743251
public function delete($id = null) {
		$country = $this->Countries->get($id);

		if ($this->Countries->delete($country)) {
			$this->Flash->success(__('record del {0} done', $id));
			return $this->redirect(['action' => 'index']);
		}

		$this->Flash->error(__('record del {0} not done exception', $id));
		return $this->redirect(['action' => 'index']);
	}
1007195
public function delete($id)
    {
        $this->preDelete($id);
        $result = $this->dataStore->delete($id);

        return $this->postDelete($result, $id);
    }
115885
public function delete(string $id)
    {
        $this->request->allowMethod(['post', 'delete']);
        $dblist = $this->Dblists->get($id);
        if ($this->Dblists->delete($dblist)) {
            $this->Flash->success('The database list has been deleted.');
        } else {
            $this->Flash->error('The database list could not be deleted. Please, try again.');
        }

        return $this->redirect(['action' => 'index']);
    }
1023142
public function actionDelete($id)
    {
        $this->findModel($id)->updateAttributes(['status' => User::STATUS_DELETED]);

        return $this->redirect(['index']);
    }