Changeset View
Changeset View
Standalone View
Standalone View
src/app/Wallet.php
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | class Wallet extends Model | ||||
{ | { | ||||
if (!$this->controllers->contains($user)) { | if (!$this->controllers->contains($user)) { | ||||
$this->controllers()->save($user); | $this->controllers()->save($user); | ||||
} | } | ||||
} | } | ||||
public function chargeEntitlements($apply = true) | public function chargeEntitlements($apply = true) | ||||
{ | { | ||||
if ($this->owner->isDraft()) { | |||||
return 0; | |||||
} | |||||
// This wallet has been created less than a month ago, this is the trial period | // This wallet has been created less than a month ago, this is the trial period | ||||
if ($this->owner->created_at >= Carbon::now()->subMonthsWithoutOverflow(1)) { | if ($this->owner->created_at >= Carbon::now()->subMonthsWithoutOverflow(1)) { | ||||
// Move all the current entitlement's updated_at timestamps forward to one month after | // Move all the current entitlement's updated_at timestamps forward to one month after | ||||
// this wallet was created. | // this wallet was created. | ||||
$freeMonthEnds = $this->owner->created_at->copy()->addMonthsWithoutOverflow(1); | $freeMonthEnds = $this->owner->created_at->copy()->addMonthsWithoutOverflow(1); | ||||
foreach ($this->entitlements()->get()->fresh() as $entitlement) { | foreach ($this->entitlements()->get()->fresh() as $entitlement) { | ||||
if ($entitlement->updated_at < $freeMonthEnds) { | if ($entitlement->updated_at < $freeMonthEnds) { | ||||
▲ Show 20 Lines • Show All 330 Lines • Show Last 20 Lines |