Changeset View
Changeset View
Standalone View
Standalone View
src/app/Group.php
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | public function assignToWallet(Wallet $wallet): Group | ||||
$sku = \App\Sku::where('title', 'group')->first(); | $sku = \App\Sku::where('title', 'group')->first(); | ||||
$exists = $wallet->entitlements()->where('sku_id', $sku->id)->count(); | $exists = $wallet->entitlements()->where('sku_id', $sku->id)->count(); | ||||
\App\Entitlement::create([ | \App\Entitlement::create([ | ||||
'wallet_id' => $wallet->id, | 'wallet_id' => $wallet->id, | ||||
'sku_id' => $sku->id, | 'sku_id' => $sku->id, | ||||
'cost' => $exists >= $sku->units_free ? $sku->cost : 0, | 'cost' => $exists >= $sku->units_free ? $sku->cost : 0, | ||||
'fee' => $exists >= $sku->units_free ? $sku->fee : 0, | |||||
'entitleable_id' => $this->id, | 'entitleable_id' => $this->id, | ||||
'entitleable_type' => Group::class | 'entitleable_type' => Group::class | ||||
]); | ]); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |