Changeset View
Changeset View
Standalone View
Standalone View
src/app/Entitlement.php
Show All 35 Lines | class Entitlement extends Model | ||||
/** | /** | ||||
* The fillable columns for this Entitlement | * The fillable columns for this Entitlement | ||||
* | * | ||||
* @var array | * @var array | ||||
*/ | */ | ||||
protected $fillable = [ | protected $fillable = [ | ||||
'sku_id', | 'sku_id', | ||||
'owner_id', | |||||
'wallet_id', | 'wallet_id', | ||||
'entitleable_id', | 'entitleable_id', | ||||
'entitleable_type', | 'entitleable_type', | ||||
'cost', | 'cost', | ||||
'description' | 'description' | ||||
]; | ]; | ||||
protected $casts = [ | protected $casts = [ | ||||
Show All 14 Lines | class Entitlement extends Model | ||||
* The SKU concerned. | * The SKU concerned. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||||
*/ | */ | ||||
public function sku() | public function sku() | ||||
{ | { | ||||
return $this->belongsTo('App\Sku'); | return $this->belongsTo('App\Sku'); | ||||
} | } | ||||
/** | /** | ||||
* The owner of this entitlement. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function owner() | |||||
{ | |||||
return $this->belongsTo('App\User', 'owner_id', 'id'); | |||||
} | |||||
/** | |||||
* The wallet this entitlement is being billed to | * The wallet this entitlement is being billed to | ||||
vanmeeuwen: I think the function `owner()` may be preserved yet changed, similar to how `App\Domain::wallet… | |||||
Done Inline ActionsI don't want to make it that simple, so we push ourselvs to think wallets not owners. There's really no need to have it as it would simply be $this->wallet()->owner. machniak: I don't want to make it that simple, so we push ourselvs to think wallets not owners. There's… | |||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||||
*/ | */ | ||||
public function wallet() | public function wallet() | ||||
{ | { | ||||
return $this->belongsTo('App\Wallet'); | return $this->belongsTo('App\Wallet'); | ||||
} | } | ||||
/** | /** | ||||
* Cost mutator. Make sure cost is integer. | * Cost mutator. Make sure cost is integer. | ||||
*/ | */ | ||||
public function setCostAttribute($cost): void | public function setCostAttribute($cost): void | ||||
{ | { | ||||
$this->attributes['cost'] = round($cost); | $this->attributes['cost'] = round($cost); | ||||
} | } | ||||
} | } |
I think the function owner() may be preserved yet changed, similar to how App\Domain::wallet() chases the domain through the entitlement to a wallet.