Changeset View
Changeset View
Standalone View
Standalone View
src/app/User.php
Show First 20 Lines • Show All 551 Lines • ▼ Show 20 Lines | public function undegrade(): void | ||||
$this->status ^= User::STATUS_DEGRADED; | $this->status ^= User::STATUS_DEGRADED; | ||||
$this->save(); | $this->save(); | ||||
} | } | ||||
/** | /** | ||||
* Un-restrict this user. | * Un-restrict this user. | ||||
* | * | ||||
* @param bool $deep Unrestrict also all users in the account | |||||
* | |||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function unrestrict(): void | public function unrestrict(bool $deep = false): void | ||||
mollekopf: includeWalletUsers or so would be better | |||||
{ | { | ||||
if (!$this->isRestricted()) { | if ($this->isRestricted()) { | ||||
return; | |||||
} | |||||
$this->status ^= User::STATUS_RESTRICTED; | $this->status ^= User::STATUS_RESTRICTED; | ||||
$this->save(); | $this->save(); | ||||
} | } | ||||
// Remove the flag from all users in the user's wallets | |||||
if ($deep) { | |||||
$this->wallets->each(function ($wallet) { | |||||
User::whereIn('id', $wallet->entitlements()->select('entitleable_id') | |||||
->where('entitleable_type', User::class)) | |||||
->each(function ($user) { | |||||
$user->unrestrict(); | |||||
}); | |||||
}); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Return users controlled by the current user. | * Return users controlled by the current user. | ||||
* | * | ||||
* @param bool $with_accounts Include users assigned to wallets | * @param bool $with_accounts Include users assigned to wallets | ||||
* the current user controls but not owns. | * the current user controls but not owns. | ||||
* | * | ||||
* @return \Illuminate\Database\Eloquent\Builder Query builder | * @return \Illuminate\Database\Eloquent\Builder Query builder | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 247 Lines • Show Last 20 Lines |
includeWalletUsers or so would be better