Skip to content

WorkspaceCreated event is defined but never dispatched #18

Description

@nfebe

src/Events/WorkspaceCreated.php defines a WorkspaceCreated event with payload (Workspace $workspace, mixed $owner), but nothing in the package dispatches it. The only reference to it under src/ is the class definition itself.

HasWorkspaces::createPersonalWorkspace() and createWorkspace() create the workspace via ownedWorkspaces()->create(...) and call joinWorkspace(), but never fire WorkspaceCreated. By contrast switchWorkspace() does dispatch WorkspaceSwitched, so the pattern is established but incomplete.

Impact

Host apps cannot react to workspace creation through the package's own event (for example, to seed per-workspace defaults such as a primary account or a default brand). They are pushed into model-level observers as a workaround, which duplicates intent the package already expresses.

Proposal

Dispatch WorkspaceCreated($workspace, $owner) when a workspace is created. Prefer firing it from the Workspace model's created boot hook so it covers every creation path (the two helper methods, factories, and direct create()), not only the helpers.

Acceptance

  • WorkspaceCreated fires once per created workspace, carrying the workspace and its owner.
  • A test asserts dispatch for both createPersonalWorkspace() and createWorkspace().

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