Changeset View
Changeset View
Standalone View
Standalone View
src/app/Handlers/Base.php
Show All 10 Lines | abstract class Base | ||||
*/ | */ | ||||
public static function entitleableClass(): string | public static function entitleableClass(): string | ||||
{ | { | ||||
return ''; | return ''; | ||||
} | } | ||||
/** | /** | ||||
* Check if the SKU is available to the user. An SKU is available | * Check if the SKU is available to the user. An SKU is available | ||||
* to the user when either it is active or there's already an | * to the user/domain when either it is active or there's already an | ||||
* active entitlement. | * active entitlement. | ||||
* | * | ||||
* @param \App\Sku $sku The SKU object | * @param \App\Sku $sku The SKU object | ||||
* @param \App\User $user The user object | * @param \App\User|\App\Domain $object The user or domain object | ||||
* | * | ||||
* @return bool | * @return bool | ||||
*/ | */ | ||||
public static function isAvailable(\App\Sku $sku, \App\User $user): bool | public static function isAvailable(\App\Sku $sku, $object): bool | ||||
{ | { | ||||
if (!$sku->active) { | if (!$sku->active) { | ||||
if (!$user->entitlements()->where('sku_id', $sku->id)->first()) { | if (!$object->entitlements()->where('sku_id', $sku->id)->first()) { | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |