🤖 Auto commit for release 'develop' on 2025-09-07

This commit is contained in:
JC5
2025-09-07 11:04:11 +02:00
parent f88286c848
commit 12e8651017
17 changed files with 35 additions and 36 deletions

View File

@@ -53,7 +53,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
/** @var GroupMembership $membership */
foreach ($memberships as $membership) {
/** @var null|User $user */
$user = $membership->user()->first();
$user = $membership->user()->first();
if (null === $user) {
continue;
}
@@ -82,8 +82,8 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
// all users are now moved away from user group.
// time to DESTROY all objects.
// we have to do this one by one to trigger the necessary observers :(
$objects = ['availableBudgets', 'bills', 'budgets', 'categories', 'currencyExchangeRates', 'objectGroups',
'recurrences', 'rules', 'ruleGroups', 'tags', 'transactionGroups', 'transactionJournals', 'piggyBanks', 'accounts', 'webhooks',
$objects = ['availableBudgets', 'bills', 'budgets', 'categories', 'currencyExchangeRates', 'objectGroups',
'recurrences', 'rules', 'ruleGroups', 'tags', 'transactionGroups', 'transactionJournals', 'piggyBanks', 'accounts', 'webhooks',
];
foreach ($objects as $object) {
foreach ($userGroup->{$object}()->get() as $item) { // @phpstan-ignore-line
@@ -110,7 +110,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
/** @var null|UserGroup $group */
$group = $membership->userGroup()->first();
if (null !== $group) {
$groupId = $group->id;
$groupId = $group->id;
if (in_array($groupId, array_keys($set), true)) {
continue;
}
@@ -135,12 +135,12 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
while ($exists && $loop < 10) {
$existingGroup = $this->findByName($groupName);
if (!$existingGroup instanceof UserGroup) {
$exists = false;
$exists = false;
/** @var UserGroup $existingGroup */
$existingGroup = $this->store(['user' => $user, 'title' => $groupName]);
}
$groupName = sprintf('%s-%s', $user->email, substr(sha1(random_int(1000, 9999) . microtime()), 0, 4));
$groupName = sprintf('%s-%s', $user->email, substr(sha1(random_int(1000, 9999).microtime()), 0, 4));
++$loop;
}
@@ -160,7 +160,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
$data['user'] = $this->user;
/** @var UserGroupFactory $factory */
$factory = app(UserGroupFactory::class);
$factory = app(UserGroupFactory::class);
return $factory->create($data);
}
@@ -191,10 +191,10 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
{
$userGroup->title = $data['title'];
$userGroup->save();
$currency = null;
$currency = null;
/** @var CurrencyRepositoryInterface $repository */
$repository = app(CurrencyRepositoryInterface::class);
$repository = app(CurrencyRepositoryInterface::class);
if (array_key_exists('primary_currency_code', $data)) {
$repository->setUser($this->user);
@@ -220,11 +220,11 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
*/
public function updateMembership(UserGroup $userGroup, array $data): UserGroup
{
$owner = UserRole::whereTitle(UserRoleEnum::OWNER)->first();
$owner = UserRole::whereTitle(UserRoleEnum::OWNER)->first();
app('log')->debug('in update membership');
/** @var null|User $user */
$user = null;
$user = null;
if (array_key_exists('id', $data)) {
/** @var null|User $user */
$user = User::find($data['id']);
@@ -263,8 +263,9 @@ class UserGroupRepository implements UserGroupRepositoryInterface, UserGroupInte
if ($membershipCount > 1) {
// group has multiple members. How many are owner, except the user we're editing now?
$ownerCount = $userGroup->groupMemberships()
->where('user_role_id', $owner->id)
->where('user_id', '!=', $user->id)->count();
->where('user_role_id', $owner->id)
->where('user_id', '!=', $user->id)->count()
;
// if there are no other owners and the current users does not get or keep the owner role, refuse.
if (
0 === $ownerCount