Skip to content

Commit ae9f58e

Browse files
simonhampclaude
andcommitted
Fix duplicate ownedTeam method and restore team plugin access logic
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0880f8f commit ae9f58e

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

app/Http/Controllers/Api/PluginAccessController.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected function getAccessiblePlugins(User $user): array
151151
}
152152
}
153153

154-
// Ultra team members get access to all official paid plugins
154+
// Team members get access to official plugins and owner's purchased plugins
155155
if ($user->isUltraTeamMember()) {
156156
$officialPlugins = Plugin::query()
157157
->where('type', \App\Enums\PluginType::Paid)
@@ -169,6 +169,27 @@ protected function getAccessiblePlugins(User $user): array
169169
}
170170
}
171171

172+
$teamOwner = $user->getTeamOwner();
173+
174+
if ($teamOwner) {
175+
$teamPlugins = $teamOwner->pluginLicenses()
176+
->active()
177+
->with('plugin:id,name')
178+
->get()
179+
->pluck('plugin')
180+
->filter()
181+
->unique('id');
182+
183+
foreach ($teamPlugins as $plugin) {
184+
if (! collect($plugins)->contains('name', $plugin->name)) {
185+
$plugins[] = [
186+
'name' => $plugin->name,
187+
'access' => 'team',
188+
];
189+
}
190+
}
191+
}
192+
172193
return $plugins;
173194
}
174195
}

app/Models/User.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,6 @@ public function developerAccount(): HasOne
127127
return $this->hasOne(DeveloperAccount::class);
128128
}
129129

130-
/**
131-
* @return HasOne<Team>
132-
*/
133-
public function ownedTeam(): HasOne
134-
{
135-
return $this->hasOne(Team::class);
136-
}
137-
138130
/**
139131
* @return HasMany<TeamUser>
140132
*/

0 commit comments

Comments
 (0)