Changeset View
Changeset View
Standalone View
Standalone View
src/app/Entitlement.php
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | class Entitlement extends Model | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function entitleable() | public function entitleable() | ||||
{ | { | ||||
return $this->morphTo()->withTrashed(); // @phpstan-ignore-line | return $this->morphTo()->withTrashed(); // @phpstan-ignore-line | ||||
} | } | ||||
/** | /** | ||||
* Returns entitleable object title (e.g. email or domain name). | |||||
* | |||||
* @return string|null An object title/name | |||||
*/ | |||||
public function entitleableTitle(): ?string | |||||
{ | |||||
if ($this->entitleable instanceof Domain) { | |||||
return $this->entitleable->namespace; | |||||
} | |||||
return $this->entitleable->email; | |||||
} | |||||
/** | |||||
* Simplified Entitlement/SKU information for a specified entitleable object | * Simplified Entitlement/SKU information for a specified entitleable object | ||||
* | * | ||||
* @param object $object Entitleable object | * @param object $object Entitleable object | ||||
* | * | ||||
* @return array Skus list with some metadata | * @return array Skus list with some metadata | ||||
*/ | */ | ||||
public static function objectEntitlementsSummary($object): array | public static function objectEntitlementsSummary($object): array | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |