Changeset View
Changeset View
Standalone View
Standalone View
src/app/Tenant.php
Show All 9 Lines | |||||
* | * | ||||
* @property int $id | * @property int $id | ||||
* @property string $title | * @property string $title | ||||
*/ | */ | ||||
class Tenant extends Model | class Tenant extends Model | ||||
{ | { | ||||
use SettingsTrait; | use SettingsTrait; | ||||
protected $fillable = [ | /** @var array<int, string> The attributes that are mass assignable */ | ||||
'id', | protected $fillable = ['id', 'title']; | ||||
'title', | |||||
]; | |||||
/** | /** | ||||
* Utility method to get tenant-specific system setting. | * Utility method to get tenant-specific system setting. | ||||
* If the setting is not specified for the tenant a system-wide value will be returned. | * If the setting is not specified for the tenant a system-wide value will be returned. | ||||
* | * | ||||
* @param int $tenantId Tenant identifier | * @param int $tenantId Tenant identifier | ||||
* @param string $key Setting name | * @param string $key Setting name | ||||
Show All 32 Lines | class Tenant extends Model | ||||
/** | /** | ||||
* Discounts assigned to this tenant. | * Discounts assigned to this tenant. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | * @return \Illuminate\Database\Eloquent\Relations\HasMany | ||||
*/ | */ | ||||
public function discounts() | public function discounts() | ||||
{ | { | ||||
return $this->hasMany('App\Discount'); | return $this->hasMany(Discount::class); | ||||
} | } | ||||
/** | /** | ||||
* 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(SignupInvitation::class); | ||||
} | } | ||||
/* | /* | ||||
* Returns the wallet of the tanant (reseller's wallet). | * Returns the wallet of the tanant (reseller's wallet). | ||||
* | * | ||||
* @return ?\App\Wallet A wallet object | * @return ?\App\Wallet A wallet object | ||||
*/ | */ | ||||
public function wallet(): ?Wallet | public function wallet(): ?Wallet | ||||
{ | { | ||||
$user = \App\User::where('role', 'reseller')->where('tenant_id', $this->id)->first(); | $user = User::where('role', 'reseller')->where('tenant_id', $this->id)->first(); | ||||
return $user ? $user->wallets->first() : null; | return $user ? $user->wallets->first() : null; | ||||
} | } | ||||
} | } |