Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/EntitlementObserver.php
Show First 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | class EntitlementObserver | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function created(Entitlement $entitlement) | public function created(Entitlement $entitlement) | ||||
{ | { | ||||
$entitlement->entitleable->updated_at = Carbon::now(); | $entitlement->entitleable->updated_at = Carbon::now(); | ||||
$entitlement->entitleable->save(); | $entitlement->entitleable->save(); | ||||
$entitlement->createTransaction(\App\Transaction::ENTITLEMENT_CREATED); | $entitlement->createTransaction(\App\Transaction::ENTITLEMENT_CREATED); | ||||
// Update the user IMAP mailbox quota | |||||
if ($entitlement->sku->title == 'storage') { | |||||
\App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* Handle the entitlement "deleted" event. | * Handle the entitlement "deleted" event. | ||||
* | * | ||||
* @param \App\Entitlement $entitlement The entitlement. | * @param \App\Entitlement $entitlement The entitlement. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function deleted(Entitlement $entitlement) | public function deleted(Entitlement $entitlement) | ||||
{ | { | ||||
if (!$entitlement->entitleable->trashed()) { | |||||
$entitlement->entitleable->updated_at = Carbon::now(); | |||||
$entitlement->entitleable->save(); | |||||
$entitlement->createTransaction(\App\Transaction::ENTITLEMENT_DELETED); | |||||
} | |||||
// Remove all configured 2FA methods from Roundcube database | // Remove all configured 2FA methods from Roundcube database | ||||
if ($entitlement->sku->title == '2fa') { | if ($entitlement->sku->title == '2fa') { | ||||
// FIXME: Should that be an async job? | // FIXME: Should that be an async job? | ||||
$sf = new \App\Auth\SecondFactor($entitlement->entitleable); | $sf = new \App\Auth\SecondFactor($entitlement->entitleable); | ||||
$sf->removeFactors(); | $sf->removeFactors(); | ||||
} | } | ||||
if (!$entitlement->entitleable->trashed()) { | // Update the user IMAP mailbox quota | ||||
$entitlement->entitleable->updated_at = Carbon::now(); | if ($entitlement->sku->title == 'storage') { | ||||
$entitlement->entitleable->save(); | \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id); | ||||
$entitlement->createTransaction(\App\Transaction::ENTITLEMENT_DELETED); | |||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Handle the entitlement "deleting" event. | * Handle the entitlement "deleting" event. | ||||
* | * | ||||
* @param \App\Entitlement $entitlement The entitlement. | * @param \App\Entitlement $entitlement The entitlement. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |