Changeset View
Changeset View
Standalone View
Standalone View
src/app/Observers/EntitlementObserver.php
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | public function deleted(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_DELETED); | $entitlement->createTransaction(\App\Transaction::ENTITLEMENT_DELETED); | ||||
} | } | ||||
/** | |||||
* Handle the entitlement "deleting" event. | |||||
* | |||||
* @param \App\Entitlement $entitlement The entitlement. | |||||
* | |||||
* @return void | |||||
*/ | |||||
public function deleting(Entitlement $entitlement) | public function deleting(Entitlement $entitlement) | ||||
{ | { | ||||
if ($entitlement->trashed()) { | |||||
return; | |||||
} | |||||
// Start calculating the costs for the consumption of this entitlement if the | // Start calculating the costs for the consumption of this entitlement if the | ||||
// existing consumption spans >= 14 days. | // existing consumption spans >= 14 days. | ||||
// | // | ||||
// Effect is that anything's free for the first 14 days | // Effect is that anything's free for the first 14 days | ||||
if ($entitlement->created_at >= Carbon::now()->subDays(14)) { | if ($entitlement->created_at >= Carbon::now()->subDays(14)) { | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |