diff --git a/src/Controller/OrganisationController.php b/src/Controller/OrganisationController.php index ffe05e2..8722a8a 100644 --- a/src/Controller/OrganisationController.php +++ b/src/Controller/OrganisationController.php @@ -359,10 +359,10 @@ class OrganisationController extends SimpleController throw new NotFoundException(); } - // Begin transaction - DB will be rolled back if an exception occurs - Capsule::transaction(function () use ($source, $target, $currentUser) { - $sourceName = $source->name; + $sourceName = $source->name; + // Begin transaction - DB will be rolled back if an exception occurs + Capsule::transaction(function () use ($source, $target, $currentUser, $sourceName) { $this->ci->get('organisation.beforeMerge')($source, $target); $source->beforeMerge($target, ['currentUser' => $currentUser]); @@ -431,10 +431,10 @@ class OrganisationController extends SimpleController throw new ForbiddenException(); } - // Begin transaction - DB will be rolled back if an exception occurs - Capsule::transaction(function () use ($organisation, $currentUser) { - $organisationName = $organisation->name; + $organisationName = $organisation->name; + // Begin transaction - DB will be rolled back if an exception occurs + Capsule::transaction(function () use ($organisation, $currentUser, $organisationName) { // Delete the organisation (soft) $organisation->delete(); unset($organisation); diff --git a/src/Controller/OrganisationRegistrationController.php b/src/Controller/OrganisationRegistrationController.php index 9ab55c9..114f3b0 100644 --- a/src/Controller/OrganisationRegistrationController.php +++ b/src/Controller/OrganisationRegistrationController.php @@ -206,10 +206,10 @@ class OrganisationRegistrationController extends SimpleController throw new ForbiddenException(); } + $organisationName = $organisation->name; + // Begin transaction - DB will be rolled back if an exception occurs - Capsule::transaction(function () use ($organisation, $currentUser) { - $organisationName = $organisation->name; - + Capsule::transaction(function () use ($organisation, $currentUser, $organisationName) { // Delete the organisation $organisation->delete(true); unset($organisation);