Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/WalletObserver.php
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | public function updated(Wallet $wallet) | ||||
$wallet->setSettings([ | $wallet->setSettings([ | ||||
'balance_negative_since' => null, | 'balance_negative_since' => null, | ||||
'balance_warning_initial' => null, | 'balance_warning_initial' => null, | ||||
'balance_warning_reminder' => null, | 'balance_warning_reminder' => null, | ||||
'balance_warning_suspended' => null, | 'balance_warning_suspended' => null, | ||||
'balance_warning_before_delete' => null, | 'balance_warning_before_delete' => null, | ||||
]); | ]); | ||||
// Unsuspend the account/domains/users | // FIXME: Since we use account degradation, should we leave suspended state untouched? | ||||
// Un-suspend and un-degrade the account/domains/users | |||||
if ($wallet->owner) { | if ($wallet->owner) { | ||||
$wallet->owner->unsuspend(); | $wallet->owner->unsuspend(); | ||||
$wallet->owner->undegrade(); | |||||
} | } | ||||
foreach ($wallet->entitlements as $entitlement) { | foreach ($wallet->entitlements as $entitlement) { | ||||
if ( | if ( | ||||
$entitlement->entitleable_type == \App\Domain::class | $entitlement->entitleable_type == \App\Domain::class | ||||
|| $entitlement->entitleable_type == \App\User::class | || $entitlement->entitleable_type == \App\User::class | ||||
) { | ) { | ||||
$entitlement->entitleable->unsuspend(); | $entitlement->entitleable->unsuspend(); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } |