/** * Delete specific object (and related objects if neccecery). * * @param bool $bulk * @return $this */ public function &delete($bulk = false) { if ($this->isLoaded()) { $this->connection->transact(function () use($bulk) { $this->triggerEvent('on_before_delete', [$bulk]); $this->connection->delete($this->table_name, $this->getWherePartById($this->getId())); $this->is_new = true; $this->triggerEvent('on_after_delete', [$bulk]); }); } return $this; }