Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/DomainObserver.php
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | class DomainObserver | ||||
* Handle the domain "restored" event. | * Handle the domain "restored" event. | ||||
* | * | ||||
* @param \App\Domain $domain The domain. | * @param \App\Domain $domain The domain. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function restored(Domain $domain) | public function restored(Domain $domain) | ||||
{ | { | ||||
// | // Restore entitlements | ||||
// FIXME: This will become problematic when we have other type of per-domain | |||||
// entitlements that shouldn't be restored with the domain | |||||
// Should we filter by SKU? | |||||
// Should we restore only these deleted last? | |||||
\App\Entitlement::withTrashed() | |||||
->where('entitleable_id', $domain->id) | |||||
->where('entitleable_type', Domain::class) | |||||
->update(['updated_at' => now(), 'deleted_at' => null]); | |||||
vanmeeuwen: When a domain is restored, we don't update the `updated_at` column of the entitlements table… | |||||
// Make sure it's not DELETED/LDAP_READY | |||||
if ($domain->isDeleted()) { | |||||
$domain->status ^= Domain::STATUS_DELETED; | |||||
} | |||||
if ($domain->isLdapReady()) { | |||||
$domain->status ^= Domain::STATUS_LDAP_READY; | |||||
} | |||||
/* FIXME: Should we also unsuspend the domain? | |||||
if ($domain->isSuspended()) { | |||||
$domain->status ^= Domain::STATUS_SUSPENDED; | |||||
} | |||||
*/ | |||||
// FIXME: Should we modify created_at/updated_at? | |||||
vanmeeuwenUnsubmitted Not Done Inline ActionsI believe created_at will remain what it was, which would be the expected result. I also believe $domain->save() will automatically update updated_at. vanmeeuwen: I believe `created_at` will remain what it was, which would be the expected result.
I also… | |||||
$domain->save(); | |||||
// Create the domain in LDAP again | |||||
\App\Jobs\Domain\CreateJob::dispatch($domain->id); | |||||
} | } | ||||
/** | /** | ||||
* Handle the domain "force deleted" event. | * Handle the domain "force deleted" event. | ||||
* | * | ||||
* @param \App\Domain $domain The domain. | * @param \App\Domain $domain The domain. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function forceDeleted(Domain $domain) | public function forceDeleted(Domain $domain) | ||||
{ | { | ||||
// | // | ||||
} | } | ||||
} | } |
When a domain is restored, we don't update the updated_at column of the entitlements table because it's used to track payment status / due dates for new charges.