Skip to main content

Overview

OptiFlow’s multi-workspace feature enables you to manage multiple business entities, branches, or departments within a single OptiFlow account. Each workspace maintains complete data isolation while allowing seamless switching between different business contexts.
Workspaces are perfect for managing multiple stores, franchises, or business units with separate inventories, customers, and financial records.

Key Capabilities

Data Isolation

Each workspace maintains its own products, contacts, invoices, and inventory completely separate from other workspaces.

Team Collaboration

Invite team members to specific workspaces with role-based access control (owner, admin, member).

Quick Switching

Switch between workspaces instantly without logging out, with your current workspace persisted in your session.

Workspace Settings

Configure workspace-specific settings, preferences, and business information for each entity.

Creating a Workspace

Workspaces can be created from your account dashboard:
// Workspace model attributes
$workspace = Workspace::create([
    'name' => 'Main Store',
    'slug' => 'main-store', // Auto-generated from name
    'description' => 'Our flagship retail location',
    'address' => '123 Main Street',
    'phone' => '+1-555-0100',
    'owner_id' => auth()->id(),
    'is_active' => true,
    'settings' => [
        // Custom workspace settings
    ],
]);

Workspace Properties

  • Name: Display name for the workspace
  • Slug: URL-friendly identifier (auto-generated)
  • Code: Optional workspace code for identification
  • Description: Brief description of the workspace
  • Address & Phone: Business contact information
  • Owner: User who created and owns the workspace
  • Settings: JSON-encoded custom settings
  • Status: Active/inactive flag

Managing Team Members

Adding Users to a Workspace

Invite team members to collaborate within a workspace:
// Add a user to workspace with role
$workspace->addUser($user, 'member');

// Check if user has access
if ($workspace->hasUser($user)) {
    // User is a member
}

// Get workspace members count
$memberCount = $workspace->members_count;

User Roles

  • Full control over workspace
  • Can delete workspace
  • Can manage all members
  • Assigned at workspace creation

Removing Team Members

// Remove a user from workspace
$workspace->removeUser($user);

Workspace Switching

Users can switch between workspaces they have access to:
// User's current workspace is stored in their profile
$user->current_workspace_id; // ID of active workspace

// Get all workspaces user has access to
$workspaces = $user->workspaces;

// Switch to different workspace
$user->update(['current_workspace_id' => $workspace->id]);
Your current workspace selection persists across sessions, so you’ll return to the same workspace when you log back in.

Workspace Scoping

OptiFlow automatically filters data based on the current workspace using the BelongsToWorkspace trait:
// Models are automatically scoped to current workspace
$products = Product::all(); // Only products in current workspace

// Access workspace relationship
$invoice->workspace; // Get workspace for an invoice
$invoice->workspace_id; // Get workspace ID

// Query across all workspaces (admin only)
$allProducts = Product::withoutWorkspaceScope()->get();
The following models are workspace-scoped:
  • Contacts (customers and suppliers)
  • Products and ProductStock
  • Invoices and Quotations
  • Inventory movements
  • Prescriptions and workflow jobs

Workspace-Specific Features

Document Subtypes

Each workspace can have preferred document subtypes:
// Set preferred invoice document subtype
$workspace->documentSubtypes()->attach($documentSubtype->id, [
    'is_preferred' => true
]);

// Get preferred document subtype
$preferredType = $workspace->getPreferredDocumentSubtype();

Workspace Invitations

Send email invitations to join a workspace:
// Get pending invitations for workspace
$invitations = $workspace->invitations;

// Invitations include email, role, and status

Use Cases

Create a workspace for each retail location. Each store manages its own inventory, customers, and sales while maintaining centralized oversight.
Set up separate workspaces for each franchise location with independent operations and reporting.
Organize different business departments (retail, wholesale, e-commerce) as separate workspaces.
Manage completely separate businesses from a single OptiFlow account.

Best Practices

Naming Convention

Use clear, descriptive names that identify the workspace’s purpose (e.g., “Downtown Store”, “Wholesale Division”).

Team Organization

Assign appropriate roles to team members based on their responsibilities and required access level.

Regular Audits

Periodically review workspace members and remove access for users who no longer need it.

API Reference

Key workspace model methods:
  • addUser(User $user, string $role) - Add a user to the workspace
  • removeUser(User $user) - Remove a user from the workspace
  • hasUser(User $user) - Check if user has access
  • getPreferredDocumentSubtype() - Get preferred document type
  • members() - Relationship to workspace users
  • invoices() - Get all invoices in workspace
  • prescriptions() - Get all prescriptions in workspace

Build docs developers (and LLMs) love