PHPackages                             whilesmart/eloquent-workspaces - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. whilesmart/eloquent-workspaces

ActiveLibrary[Framework](/categories/framework)

whilesmart/eloquent-workspaces
==============================

Workspace management package for Laravel applications

1.1.1(2w ago)0170↑66.7%[5 issues](https://github.com/whilesmartphp/eloquent-workspaces/issues)[1 PRs](https://github.com/whilesmartphp/eloquent-workspaces/pulls)1MITPHPPHP ^8.2CI passing

Since Nov 16Pushed 2w agoCompare

[ Source](https://github.com/whilesmartphp/eloquent-workspaces)[ Packagist](https://packagist.org/packages/whilesmart/eloquent-workspaces)[ RSS](/packages/whilesmart-eloquent-workspaces/feed)WikiDiscussions dev Synced yesterday

READMEChangelog (6)Dependencies (18)Versions (18)Used By (1)

Eloquent Workspaces
===================

[](#eloquent-workspaces)

A comprehensive Laravel package for managing workspaces, invitations, and member roles.

Quick Start
-----------

[](#quick-start)

```
composer require whilesmart/eloquent-workspaces
php artisan migrate
```

That's it! The package will auto-register routes and work out of the box.

Environment Variables
---------------------

[](#environment-variables)

All package configuration is environment-driven. Add these variables to your `.env` file:

### Core Settings

[](#core-settings)

```
# The user model class that will be used for workspace relationships.
WORKSPACES_USER_MODEL=App\\Models\\User

# The workspace model class. Point this at your own subclass (extending the
# base Workspace model) to compose extra traits/behaviour; it is honoured by
# the HasWorkspaces relations, role-context queries, and route-model binding.
WORKSPACES_MODEL=App\\Models\\Workspace

# Enable or disable route registration (default: true)
WORKSPACES_REGISTER_ROUTES=true

# Route prefix for all workspace endpoints (default: api)
WORKSPACES_ROUTE_PREFIX=api
```

### Custom workspace model

[](#custom-workspace-model)

```
// config/workspaces.php
'workspace_model' => App\Models\Workspace::class,
```

```
use Whilesmart\Workspaces\Models\Workspace as BaseWorkspace;

class Workspace extends BaseWorkspace
{
    // compose your own capabilities (HasInvoices, HasBrands, Configurable, …)
}
```

With this set, `$user->workspaces()`, `currentOrDefaultWorkspace()`, route-bound `{workspace}` params, and role checks all return / use your subclass — no re-resolving in the host app.

### Workspace Settings

[](#workspace-settings)

```
# Automatically create a personal workspace for a user on registration (default: true)
WORKSPACES_AUTO_CREATE=true
```

### Invitation Settings

[](#invitation-settings)

```
# Number of days an invitation is valid (default: 7)
WORKSPACES_INVITATION_EXPIRY=7
```

Advanced Configuration
----------------------

[](#advanced-configuration)

For more advanced configuration, you can publish the configuration file:

```
php artisan vendor:publish --tag="workspaces-config"
```

This will create a `config/workspaces.php` file in your application.

### `route_middleware`

[](#route_middleware)

You can specify middleware for the workspace routes.

```
'route_middleware' => ['auth:sanctum'],
```

### `personal_workspace_name_template`

[](#personal_workspace_name_template)

This template is used to name the personal workspace created for a new user. Available variables: `{first_name}`, `{last_name}`, `{full_name}`

```
'personal_workspace_name_template' => "{first_name}'s Workspace",
```

### `roles`

[](#roles)

Define the roles available in a workspace.

```
'roles' => [
    'owner' => 'owner',
    'admin' => 'admin',
    'member' => 'member',
],
```

Available Endpoints
-------------------

[](#available-endpoints)

The `{workspace}` parameter is resolved by slug.

### Workspaces

[](#workspaces)

- `GET /api/workspaces` - List the authenticated user's workspaces
- `POST /api/workspaces` - Create a workspace
- `GET /api/workspaces/{workspace}` - Get a workspace
- `PUT /api/workspaces/{workspace}` - Update a workspace
- `DELETE /api/workspaces/{workspace}` - Delete a workspace
- `POST /api/workspaces/{workspace}/switch` - Switch to a workspace

### Members

[](#members)

- `GET /api/workspaces/{workspace}/members` - Get workspace members
- `DELETE /api/workspaces/{workspace}/members/{userId}` - Remove a member from a workspace
- `POST /api/workspaces/{workspace}/leave` - Leave a workspace

### Invitations

[](#invitations)

- `POST /api/workspaces/{workspace}/members/invite` - Invite a member to a workspace
- `GET /api/workspaces/{workspace}/invitations` - List pending invitations
- `DELETE /api/workspaces/{workspace}/invitations/{invitation}` - Cancel a pending invitation
- `POST /api/workspaces/invitations/{token}/accept` - Accept an invitation
- `POST /api/workspaces/invitations/{token}/decline` - Decline an invitation

Accept and decline are keyed on the invitation token (the value carried in the invite). The authenticated user's email must match the address the invitation was sent to.

Events
------

[](#events)

The package dispatches the following events, which a host application can listen for:

- `MemberInvited` - an invitation was created (carries the workspace and the invitation). Listen for this to deliver the invitation email.
- `MemberJoined` - an invited user accepted and joined (carries the workspace, the member, and the role).
- `WorkspaceSwitched` - a user switched their current workspace (carries the new workspace, the user, and the previous workspace).

Publishing Assets
-----------------

[](#publishing-assets)

You can publish the package's assets using the following commands:

```
# Publish only configuration
php artisan vendor:publish --tag="workspaces-config"

# Publish only migrations
php artisan vendor:publish --tag="workspaces-migrations"

# Publish everything
php artisan vendor:publish --provider="Whilesmart\\Workspaces\\WorkspacesServiceProvider"
```

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance96

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~41 days

Recently: every ~52 days

Total

6

Last Release

19d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1ca6f6e01ecbfe6640ff410c4f0321054fb48d05a5f843c2b89887b90369bcd?d=identicon)[whilesmart](/maintainers/whilesmart)

---

Top Contributors

[![nfebe](https://avatars.githubusercontent.com/u/14317775?v=4)](https://github.com/nfebe "nfebe (13 commits)")[![kofimokome](https://avatars.githubusercontent.com/u/21100923?v=4)](https://github.com/kofimokome "kofimokome (9 commits)")

---

Tags

laravelteamteamsworkspaceworkspaces

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/whilesmart-eloquent-workspaces/health.svg)

```
[![Health](https://phpackages.com/badges/whilesmart-eloquent-workspaces/health.svg)](https://phpackages.com/packages/whilesmart-eloquent-workspaces)
```

###  Alternatives

[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[bagisto/bagisto

Bagisto Laravel E-Commerce

27.6k172.1k9](/packages/bagisto-bagisto)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
