Changeset View
Changeset View
Standalone View
Standalone View
src/app/Transaction.php
Show All 22 Lines | class Transaction extends Model | ||||
public const ENTITLEMENT_BILLED = 'billed'; | public const ENTITLEMENT_BILLED = 'billed'; | ||||
public const ENTITLEMENT_CREATED = 'created'; | public const ENTITLEMENT_CREATED = 'created'; | ||||
public const ENTITLEMENT_DELETED = 'deleted'; | public const ENTITLEMENT_DELETED = 'deleted'; | ||||
public const WALLET_AWARD = 'award'; | public const WALLET_AWARD = 'award'; | ||||
public const WALLET_CREDIT = 'credit'; | public const WALLET_CREDIT = 'credit'; | ||||
public const WALLET_DEBIT = 'debit'; | public const WALLET_DEBIT = 'debit'; | ||||
public const WALLET_PENALTY = 'penalty'; | public const WALLET_PENALTY = 'penalty'; | ||||
public const WALLET_REFUND = 'refund'; | |||||
public const WALLET_CHARGEBACK = 'chback'; | |||||
protected $fillable = [ | protected $fillable = [ | ||||
// actor, if any | // actor, if any | ||||
'user_email', | 'user_email', | ||||
// entitlement, wallet | // entitlement, wallet | ||||
'object_id', | 'object_id', | ||||
'object_type', | 'object_type', | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | public function setTypeAttribute($value): void | ||||
// TODO: Must be an entitlement. | // TODO: Must be an entitlement. | ||||
$this->attributes['type'] = $value; | $this->attributes['type'] = $value; | ||||
break; | break; | ||||
case self::WALLET_AWARD: | case self::WALLET_AWARD: | ||||
case self::WALLET_CREDIT: | case self::WALLET_CREDIT: | ||||
case self::WALLET_DEBIT: | case self::WALLET_DEBIT: | ||||
case self::WALLET_PENALTY: | case self::WALLET_PENALTY: | ||||
case self::WALLET_REFUND: | |||||
case self::WALLET_CHARGEBACK: | |||||
// TODO: This must be a wallet. | // TODO: This must be a wallet. | ||||
$this->attributes['type'] = $value; | $this->attributes['type'] = $value; | ||||
break; | break; | ||||
default: | default: | ||||
throw new \Exception("Invalid type value"); | throw new \Exception("Invalid type value"); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Returns a short text describing the transaction. | * Returns a short text describing the transaction. | ||||
* | * | ||||
* @return string The description | * @return string The description | ||||
*/ | */ | ||||
public function shortDescription(): string | public function shortDescription(): string | ||||
{ | { | ||||
$label = $this->objectTypeToLabelString() . '-' . $this->{'type'} . '-short'; | $label = $this->objectTypeToLabelString() . '-' . $this->{'type'} . '-short'; | ||||
return \trans("transactions.{$label}", $this->descriptionParams()); | $result = \trans("transactions.{$label}", $this->descriptionParams()); | ||||
return trim($result, ': '); | |||||
} | } | ||||
/** | /** | ||||
* Returns a text describing the transaction. | * Returns a text describing the transaction. | ||||
* | * | ||||
* @return string The description | * @return string The description | ||||
*/ | */ | ||||
public function toString(): string | public function toString(): string | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |