public function disableConstraints(callable $callback) { $this->disableForeignKeys(); try { $result = $callback($this); } catch (Exception $e) { $this->enableForeignKeys(); throw $e; } $this->enableForeignKeys(); return $result; }