Changeset View
Changeset View
Standalone View
Standalone View
src/app/User.php
Show First 20 Lines • Show All 628 Lines • ▼ Show 20 Lines | class User extends Authenticatable implements JWTSubject | ||||
/** | /** | ||||
* Returns the wallet by which the user is controlled | * Returns the wallet by which the user is controlled | ||||
* | * | ||||
* @return ?\App\Wallet A wallet object | * @return ?\App\Wallet A wallet object | ||||
*/ | */ | ||||
public function wallet(): ?Wallet | public function wallet(): ?Wallet | ||||
{ | { | ||||
$entitlement = $this->entitlement()->withTrashed()->first(); | $entitlement = $this->entitlement()->withTrashed()->orderBy('created_at', 'desc')->first(); | ||||
// TODO: No entitlement should not happen, but in tests we have | // TODO: No entitlement should not happen, but in tests we have | ||||
// such cases, so we fallback to the user's wallet in this case | // such cases, so we fallback to the user's wallet in this case | ||||
return $entitlement ? $entitlement->wallet : $this->wallets()->first(); | return $entitlement ? $entitlement->wallet : $this->wallets()->first(); | ||||
} | } | ||||
/** | /** | ||||
* Wallets this user owns. | * Wallets this user owns. | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |