Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AffData's avatar

JetStream current team as session or show current team's settings without passing it in the URL?

I'm altering the logic behind Jetstream a little because I personally think it's not the best practice (UX-wise) to let users change settings of teams which are not marked as their current team.

Currently, if I have teamId: 1 selected and go to /teams/2 let's say – I can edit team 2's settings while still having team 1 selected as my current team.

What would be the best way to always show the currently selected team without passing the teamId as the URL parameter? Ideally my route should be /settings/workspace and always show the information of the currently selected team while maintaining all the benefits of Jetstream.

Route::get('/settings/workspace', [TeamController::class, 'show'])->name('settings.workspace');

Using Inertia and React for the frontend:

<SettingsNavItem
        title="Workspace Settings"
        href={route('settings.workspace', [
          page.props.auth.user.current_team,
        ])}
        active={route().current('settings.workspace')}
      />
0 likes
1 reply
AffData's avatar

For anyone having this question in the future, I have created an alternative TeamController and copied the show method from the one used by Jetstream.

Then I changed the functionality slightly so instead of accepting a teamId it now looks for the user in the request and finds the user's currentTeam to then render its settings page.

public function show(Request $request)
    {
        $user = $request->user();
        $team = $user->currentTeam;

        if (!$team) {
            return inertia()->render('Dashboard', [
                'error' => 'You are not a member of any workspace.'
            ]);
        }

        Gate::authorize('view', $team);

        return Jetstream::inertia()->render($request, 'Teams/Show', [
            'team' => $team->load('owner', 'users', 'teamInvitations'),
            'availableRoles' => array_values(Jetstream::$roles),
            'availablePermissions' => Jetstream::$permissions,
            'defaultPermissions' => Jetstream::$defaultPermissions,
            'permissions' => [
                'canAddTeamMembers' => Gate::check('addTeamMember', $team),
                'canDeleteTeam' => Gate::check('delete', $team),
                'canRemoveTeamMembers' => Gate::check('removeTeamMember', $team),
                'canUpdateTeam' => Gate::check('update', $team),
                'canUpdateTeamMembers' => Gate::check('updateTeamMember', $team),
            ],
        ]);
    }

Please or to participate in this conversation.