Changeset View
Changeset View
Standalone View
Standalone View
src/app/Wallet.php
Show First 20 Lines • Show All 349 Lines • ▼ Show 20 Lines | class Wallet extends Model | ||||
* Ranges from 0.00 to 1.00. | * Ranges from 0.00 to 1.00. | ||||
*/ | */ | ||||
public function getDiscountRate() | public function getDiscountRate() | ||||
{ | { | ||||
return (100 - $this->getDiscount()) / 100; | return (100 - $this->getDiscount()) / 100; | ||||
} | } | ||||
/** | /** | ||||
* Check if the specified user is a controller to this wallet. | |||||
* | |||||
* @param \App\User $user The user object. | |||||
* | |||||
* @return bool True if the user is one of the wallet controllers (including user), False otherwise | |||||
*/ | |||||
public function isController(User $user): bool | |||||
{ | |||||
return $user->id == $this->user_id || $this->controllers->contains($user); | |||||
} | |||||
/** | |||||
* A helper to display human-readable amount of money using | * A helper to display human-readable amount of money using | ||||
* the wallet currency and specified locale. | * the wallet currency and specified locale. | ||||
* | * | ||||
* @param int $amount A amount of money (in cents) | * @param int $amount A amount of money (in cents) | ||||
* @param string $locale A locale for the output | * @param string $locale A locale for the output | ||||
* | * | ||||
* @return string String representation, e.g. "9.99 CHF" | * @return string String representation, e.g. "9.99 CHF" | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines |