public function transactional(callable $callable) { $this->beginTransaction(); try { $result = $callable($this); $this->commit(); } catch (\Exception $e) { $this->rollback(); throw $e; } return $result ?: true; }