When restoring an organisation that was rejected, revert the approval request as well
This commit is contained in:
@@ -593,6 +593,10 @@ class OrganisationController extends SimpleController
|
|||||||
|
|
||||||
// Begin transaction - DB will be rolled back if an exception occurs
|
// Begin transaction - DB will be rolled back if an exception occurs
|
||||||
Capsule::transaction(function () use ($organisation, $currentUser) {
|
Capsule::transaction(function () use ($organisation, $currentUser) {
|
||||||
|
if (!$organisation->flag_approved) {
|
||||||
|
$verification = $this->ci->repoOrganisationApproval->revert($organisation);
|
||||||
|
}
|
||||||
|
|
||||||
$organisation->restore();
|
$organisation->restore();
|
||||||
|
|
||||||
// Create activity record
|
// Create activity record
|
||||||
|
|||||||
@@ -114,6 +114,34 @@ class OrganisationApprovalRepository extends TokenRepository
|
|||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverts a token request without requiring the token (admin overrride)
|
||||||
|
*/
|
||||||
|
public function revert(OrganisationInterface $organisation)
|
||||||
|
{
|
||||||
|
$model = $this->classMapper->getClassMapping($this->modelIdentifier)::query()
|
||||||
|
->where('organisation_id', $organisation->id)
|
||||||
|
->where('completed', true)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($model === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Begin transaction - DB will be rolled back if an exception occurs
|
||||||
|
Capsule::transaction(function () use ($model) {
|
||||||
|
$model->fill([
|
||||||
|
'completed' => false,
|
||||||
|
'completed_at' => null,
|
||||||
|
'approver_id' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$model->save();
|
||||||
|
});
|
||||||
|
|
||||||
|
return $model;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user