Changeset View
Changeset View
Standalone View
Standalone View
src/app/Tenant.php
Show All 31 Lines | class Tenant extends Model | ||||
* SignupInvitations assigned to this tenant. | * SignupInvitations assigned to this tenant. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | * @return \Illuminate\Database\Eloquent\Relations\HasMany | ||||
*/ | */ | ||||
public function signupInvitations() | public function signupInvitations() | ||||
{ | { | ||||
return $this->hasMany('App\SignupInvitation'); | return $this->hasMany('App\SignupInvitation'); | ||||
} | } | ||||
/* | |||||
* Returns the wallet of the tanant (reseller's wallet). | |||||
* | |||||
* @return ?\App\Wallet A wallet object | |||||
*/ | |||||
public function wallet(): ?Wallet | |||||
{ | |||||
$user = \App\User::where('role', 'reseller')->where('tenant_id', $this->id)->first(); | |||||
return $user ? $user->wallets->first() : null; | |||||
} | |||||
} | } |