Changeset View
Changeset View
Standalone View
Standalone View
src/app/Jobs/WalletCheck.php
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | protected function suspendAccount() | ||||
// Sanity check, already deleted | // Sanity check, already deleted | ||||
if (!$this->wallet->owner) { | if (!$this->wallet->owner) { | ||||
return; | return; | ||||
} | } | ||||
// Suspend the account | // Suspend the account | ||||
$this->wallet->owner->suspend(); | $this->wallet->owner->suspend(); | ||||
foreach ($this->wallet->entitlements as $entitlement) { | foreach ($this->wallet->entitlements as $entitlement) { | ||||
if ( | if (method_exists($entitlement->entitleable_type, 'suspend')) { | ||||
mollekopf: I suppose the call won't hurt, but checking for the method doesn't check if the entitleable is… | |||||
Done Inline ActionsThat's right, but the method does nothing for objects that do not support suspend, so we're good.. I find this approach more generic and simpler. machniak: That's right, but the method does nothing for objects that do not support suspend, so we're… | |||||
$entitlement->entitleable_type == \App\Domain::class | |||||
|| $entitlement->entitleable_type == \App\User::class | |||||
) { | |||||
$entitlement->entitleable->suspend(); | $entitlement->entitleable->suspend(); | ||||
} | } | ||||
} | } | ||||
$this->sendMail(\App\Mail\NegativeBalanceSuspended::class, true); | $this->sendMail(\App\Mail\NegativeBalanceSuspended::class, true); | ||||
$now = \Carbon\Carbon::now()->toDateTimeString(); | $now = \Carbon\Carbon::now()->toDateTimeString(); | ||||
$this->wallet->setSetting('balance_warning_suspended', $now); | $this->wallet->setSetting('balance_warning_suspended', $now); | ||||
▲ Show 20 Lines • Show All 188 Lines • Show Last 20 Lines |
I suppose the call won't hurt, but checking for the method doesn't check if the entitleable is suspendable due to the trait (the method exists even if the constant doesn't).