Changeset View
Changeset View
Standalone View
Standalone View
src/app/Wallet.php
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | public function chargeEntitlements($apply = true) | ||||
$this->debit($entitlement->cost * $diff); | $this->debit($entitlement->cost * $diff); | ||||
} | } | ||||
} | } | ||||
return $charges; | return $charges; | ||||
} | } | ||||
/** | /** | ||||
vanmeeuwen: No additional whitespace is needed here, right? | |||||
* Calculate the expected charges to this wallet. | * Calculate the expected charges to this wallet. | ||||
* | * | ||||
* @return int | * @return int | ||||
*/ | */ | ||||
public function expectedCharges() | public function expectedCharges() | ||||
{ | { | ||||
return $this->chargeEntitlements(false); | return $this->chargeEntitlements(false); | ||||
} | } | ||||
Show All 10 Lines | public function removeController(User $user) | ||||
if ($this->controllers->contains($user)) { | if ($this->controllers->contains($user)) { | ||||
$this->controllers()->detach($user); | $this->controllers()->detach($user); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Add an amount of pecunia to this wallet's balance. | * Add an amount of pecunia to this wallet's balance. | ||||
* | * | ||||
* @param float $amount The amount of pecunia to add. | * @param int $amount The amount of pecunia to add (in cents). | ||||
* | * | ||||
* @return Wallet | * @return Wallet Self | ||||
*/ | */ | ||||
public function credit(float $amount) | public function credit(int $amount): Wallet | ||||
{ | { | ||||
$this->balance += $amount; | $this->balance += $amount; | ||||
$this->save(); | $this->save(); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Deduct an amount of pecunia from this wallet's balance. | * Deduct an amount of pecunia from this wallet's balance. | ||||
* | * | ||||
* @param float $amount The amount of pecunia to deduct. | * @param int $amount The amount of pecunia to deduct (in cents). | ||||
* | * | ||||
* @return Wallet | * @return Wallet Self | ||||
*/ | */ | ||||
public function debit(float $amount) | public function debit(int $amount): Wallet | ||||
{ | { | ||||
$this->balance -= $amount; | $this->balance -= $amount; | ||||
$this->save(); | $this->save(); | ||||
return $this; | return $this; | ||||
} | } | ||||
Show All 26 Lines | class Wallet extends Model | ||||
* The owner of the wallet -- the wallet is in his/her back pocket. | * The owner of the wallet -- the wallet is in his/her back pocket. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||||
*/ | */ | ||||
public function owner() | public function owner() | ||||
{ | { | ||||
return $this->belongsTo('App\User', 'user_id', 'id'); | return $this->belongsTo('App\User', 'user_id', 'id'); | ||||
} | } | ||||
/** | |||||
* Payments on this wallet. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | |||||
*/ | |||||
public function payments() | |||||
{ | |||||
return $this->hasMany('App\Payment'); | |||||
} | |||||
} | } |
No additional whitespace is needed here, right?