public function transaction(\Closure $task) {
        try {
            $this->db()->begin();
            $result = $task();
            $this->db()->commit();
            return $result;
        }
        catch (\Exception $ex) {
            $this->db()->rollback();
            throw $ex;
        }
    }