$result = null; DB::transaction(function () use(&$result) { // logic here $result = someGetResult(); }); if ($result != null) { }