Changeset View
Changeset View
Standalone View
Standalone View
src/app/Entitlement.php
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | protected $fillable = [ | ||||
'description' | 'description' | ||||
]; | ]; | ||||
protected $casts = [ | protected $casts = [ | ||||
'cost' => 'integer', | 'cost' => 'integer', | ||||
]; | ]; | ||||
/** | /** | ||||
* Create a transaction record for this entitlement. | |||||
* | |||||
* @param string $type The type of transaction ('created', 'billed', 'deleted'), but use the | |||||
machniak: $type is a string, and the labels in comment are wrong. | |||||
Done Inline ActionsYes. vanmeeuwen: Yes. | |||||
* \App\Transaction constants. | |||||
* @param int $amount The amount involved in cents | |||||
* | |||||
* @return string The transaction ID | |||||
*/ | |||||
public function createTransaction($type, $amount = null) | |||||
{ | |||||
$transaction = \App\Transaction::create( | |||||
[ | |||||
'user_email' => \App\Utils::userEmailOrNull(), | |||||
'object_id' => $this->id, | |||||
'object_type' => \App\Entitlement::class, | |||||
'type' => $type, | |||||
'amount' => $amount | |||||
] | |||||
); | |||||
return $transaction->id; | |||||
} | |||||
/** | |||||
* Principally entitleable objects such as 'Domain' or 'User'. | * Principally entitleable objects such as 'Domain' or 'User'. | ||||
* | * | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
public function entitleable() | public function entitleable() | ||||
{ | { | ||||
return $this->morphTo(); | return $this->morphTo()->withTrashed(); | ||||
} | } | ||||
/** | /** | ||||
* The SKU concerned. | * The SKU concerned. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||||
*/ | */ | ||||
public function sku() | public function sku() | ||||
Show All 22 Lines |
$type is a string, and the labels in comment are wrong.