Changeset View
Changeset View
Standalone View
Standalone View
src/app/Wallet.php
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | public function controllers() | ||||
'App\User', // The foreign object definition | 'App\User', // The foreign object definition | ||||
'user_accounts', // The table name | 'user_accounts', // The table name | ||||
'wallet_id', // The local foreign key | 'wallet_id', // The local foreign key | ||||
'user_id' // The remote foreign key | 'user_id' // The remote foreign key | ||||
); | ); | ||||
} | } | ||||
/** | /** | ||||
* Retrieve the costs per day of everything charged to this wallet. | |||||
* | |||||
* @return float | |||||
*/ | |||||
public function costsPerDay() | |||||
{ | |||||
$costs = (float) 0; | |||||
foreach ($this->entitlements as $entitlement) { | |||||
$costs += $entitlement->costsPerDay(); | |||||
} | |||||
return $costs; | |||||
} | |||||
/** | |||||
* Add an amount of pecunia to this wallet's balance. | * Add an amount of pecunia to this wallet's balance. | ||||
* | * | ||||
* @param int $amount The amount of pecunia to add (in cents). | * @param int $amount The amount of pecunia to add (in cents). | ||||
* | * | ||||
* @return Wallet Self | * @return Wallet Self | ||||
*/ | */ | ||||
public function credit(int $amount): Wallet | public function credit(int $amount): Wallet | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |