Changeset View
Changeset View
Standalone View
Standalone View
src/app/User.php
Show First 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | public function domains() | ||||
\Log::info("Found domain {$this->email}: {$domain->namespace} (charged)"); | \Log::info("Found domain {$this->email}: {$domain->namespace} (charged)"); | ||||
$domains[] = $domain; | $domains[] = $domain; | ||||
} | } | ||||
} | } | ||||
return $domains; | return $domains; | ||||
} | } | ||||
/** | |||||
* The user entitlement. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\MorphOne | |||||
*/ | |||||
public function entitlement() | public function entitlement() | ||||
{ | { | ||||
return $this->morphOne('App\Entitlement', 'entitleable'); | return $this->morphOne('App\Entitlement', 'entitleable'); | ||||
} | } | ||||
/** | /** | ||||
* Entitlements for this user. | * Entitlements for this user. | ||||
* | * | ||||
* Note that these are entitlements that apply to the user account, and not entitlements that | * Note that these are entitlements that apply to the user account, and not entitlements that | ||||
* this user owns. | * this user owns. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | * @return \Illuminate\Database\Eloquent\Relations\HasMany | ||||
*/ | */ | ||||
public function entitlements() | public function entitlements() | ||||
{ | { | ||||
return $this->hasMany('App\Entitlement', 'entitleable_id', 'id'); | return $this->hasMany('App\Entitlement', 'entitleable_id', 'id') | ||||
->where('entitleable_type', User::class); | |||||
} | } | ||||
public function addEntitlement($entitlement) | public function addEntitlement($entitlement) | ||||
{ | { | ||||
if (!$this->entitlements->contains($entitlement)) { | if (!$this->entitlements->contains($entitlement)) { | ||||
return $this->entitlements()->save($entitlement); | return $this->entitlements()->save($entitlement); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |