public function transaction($callback)
    {
        $connection = $this->getConnection();
        $connection->beginTransaction();

        if ($callback instanceof Closure) {
            $callback = $callback->bindTo($this, get_class($this));
        }

        if (call_user_func($callback, $this) === false) {
            $connection->rollBack();
        } else {
            $connection->commit();
        }

        return $this;
    }