remove app from user organization
This commit is contained in:
parent
fed351b433
commit
8eb5cf433d
|
|
@ -207,15 +207,16 @@ readonly class UserOrganizationService
|
||||||
$uoEntity = $this->entityManager
|
$uoEntity = $this->entityManager
|
||||||
->getRepository(UsersOrganizations::class)
|
->getRepository(UsersOrganizations::class)
|
||||||
->findOneBy(['users' => $user, 'organization' => $organization, 'role' => $roleUser]);
|
->findOneBy(['users' => $user, 'organization' => $organization, 'role' => $roleUser]);
|
||||||
// dd($roleUser);
|
// dd($uoEntity->getApps()->toArray());
|
||||||
// 1. Remove apps that are no longer selected
|
// 1. Remove apps that are no longer selected
|
||||||
foreach ($uoEntity->getApps() as $existingApp) {
|
foreach ($uoEntity->getApps()->toArray() as $existingApp) {
|
||||||
if (!in_array($existingApp->getId(), $selectedApps)) {
|
if (!in_array($existingApp->getId(), $selectedApps)) {
|
||||||
|
|
||||||
$uoEntity->removeApp($existingApp);
|
$uoEntity->removeApp($existingApp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Add newly selected apps (your existing logic)
|
// 2. Add newly selected apps
|
||||||
foreach ($selectedApps as $appId) {
|
foreach ($selectedApps as $appId) {
|
||||||
$appEntity = $this->entityManager->getRepository(Apps::class)->find($appId);
|
$appEntity = $this->entityManager->getRepository(Apps::class)->find($appId);
|
||||||
if ($appEntity && !$uoEntity->getApps()->contains($appEntity)) {
|
if ($appEntity && !$uoEntity->getApps()->contains($appEntity)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue