Changeset View
Changeset View
Standalone View
Standalone View
src/app/User.php
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | class User extends Authenticatable implements JWTSubject | ||||
* | * | ||||
* @return Domain[] List of Domain objects | * @return Domain[] List of Domain objects | ||||
*/ | */ | ||||
public function domains(): array | public function domains(): array | ||||
{ | { | ||||
if ($this->tenant_id) { | if ($this->tenant_id) { | ||||
$domains = Domain::where('tenant_id', $this->tenant_id); | $domains = Domain::where('tenant_id', $this->tenant_id); | ||||
} else { | } else { | ||||
$domains = Domain::withEnvTenant(); | $domains = Domain::withEnvTenantContext(); | ||||
} | } | ||||
$domains = $domains->whereRaw(sprintf('(type & %s)', Domain::TYPE_PUBLIC)) | $domains = $domains->whereRaw(sprintf('(type & %s)', Domain::TYPE_PUBLIC)) | ||||
->whereRaw(sprintf('(status & %s)', Domain::STATUS_ACTIVE)) | ->whereRaw(sprintf('(status & %s)', Domain::STATUS_ACTIVE)) | ||||
->get() | ->get() | ||||
->all(); | ->all(); | ||||
foreach ($this->wallets as $wallet) { | foreach ($this->wallets as $wallet) { | ||||
▲ Show 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | class User extends Authenticatable implements JWTSubject | ||||
/** | /** | ||||
* Check if user has an entitlement for the specified SKU. | * Check if user has an entitlement for the specified SKU. | ||||
* | * | ||||
* @param string $title The SKU title | * @param string $title The SKU title | ||||
* | * | ||||
* @return bool True if specified SKU entitlement exists | * @return bool True if specified SKU entitlement exists | ||||
*/ | */ | ||||
public function hasSku($title): bool | public function hasSku(string $title): bool | ||||
{ | { | ||||
$sku = Sku::where('title', $title)->first(); | $sku = Sku::withObjectTenantContext($this)->where('title', $title)->first(); | ||||
if (!$sku) { | if (!$sku) { | ||||
return false; | return false; | ||||
} | } | ||||
return $this->entitlements()->where('sku_id', $sku->id)->count() > 0; | return $this->entitlements()->where('sku_id', $sku->id)->count() > 0; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines |