Skip to content

Add first-class current/active workspace support #14

Description

@nfebe

Problem

The package exposes switchWorkspace(), currentWorkspace(), and currentOrDefaultWorkspace() on the HasWorkspaces trait, plus a switchTo controller action. But:

  1. No storage — currentWorkspace() only works if the host app implements getCurrentWorkspaceId()/setCurrentWorkspaceId(). Every consumer reinvents this.
  2. No read endpoint — there's no GET /workspaces/current to fetch the active workspace, so each app maintains a bespoke controller for it.

What we do today (workaround)

In the host app we back the hooks with whilesmart/eloquent-model-configuration, storing current_workspace_id as a user config value, and we keep a one-method app controller just to expose the current workspace (id, name, currency) to the frontend.

Proposed

  • Provide a default storage implementation for current workspace (optionally via eloquent-model-configuration when present, else a current_workspace_id column / cache), so apps don't implement the hooks themselves.
  • Add a GET /workspaces/current endpoint returning the current-or-default workspace, so the bespoke app controller can be dropped.

Tracking the app-side glue against this issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions