PHPackages                             whilesmart/eloquent-organizations - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. whilesmart/eloquent-organizations

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

whilesmart/eloquent-organizations
=================================

Organization management package for Laravel applications

v1.2.0(2w ago)0337[1 issues](https://github.com/whilesmartphp/eloquent-organizations/issues)MITPHPPHP ^8.2CI passing

Since Sep 17Pushed 2w agoCompare

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

READMEChangelog (3)Dependencies (23)Versions (14)Used By (0)

Whilesmart Eloquent Organizations
=================================

[](#whilesmart-eloquent-organizations)

Organization management package for Laravel applications with role-based access control and workspace integration.

[![Latest Version on Packagist](https://camo.githubusercontent.com/75520a80d054ffb491d67c1194cafb8f52e9f031bdc5c487345634941a8dd451/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7768696c65736d6172742f656c6f7175656e742d6f7267616e697a6174696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/whilesmart/eloquent-organizations)

Features
--------

[](#features)

- **Organization Management**: Complete CRUD operations for organizations
- **Role Integration**: Built-in support for role-based access control
- **Workspace Scoping**: Optional workspace-level organization isolation
- **Polymorphic Ownership**: Organizations can be owned by any model (User, Team, etc.)
- **API Ready**: Pre-built RESTful API endpoints
- **Laravel Auto-Discovery**: Automatically registers service provider
- **Flexible Configuration**: Customizable settings and behavior

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require whilesmart/eloquent-organizations
```

The package will automatically register its service provider.

### Publish Configuration

[](#publish-configuration)

Optionally publish the configuration file:

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

### Customize Routes

[](#customize-routes)

Applications can keep package-owned routes while replacing only the behavior they need:

```
'controller' => \App\Http\Controllers\OrganizationController::class,
'model' => \App\Models\Organization::class,
'resource' => \App\Http\Resources\OrganizationResource::class,
'response_formatter' => \App\Http\Responses\OrganizationResponseFormatter::class,
'hooks' => [\App\Organizations\OrganizationHook::class],
'route_actions' => ['index', 'store', 'show'],
'route_write_middleware' => ['workspace.write'],
'register_workspace_routes' => false,
'register_member_routes' => false,
```

The custom model and resource extend their package defaults. The response formatter implements the package contract. The custom controller remains the final escape hatch. Write middleware applies to create, update, delete, and member write routes that remain enabled.

Hooks implement `OrganizationHook`. Their `before` method receives the request before validation, and their `after` method receives responses returned by the controller. Both methods receive an `OrganizationAction` value identifying the operation. Hooks are resolved through the container.

Successful member role changes dispatch `OrganizationMemberAddedEvent` and `OrganizationMemberRemovedEvent`. Each event contains the organization, affected member model, and role.

Usage
-----

[](#usage)

### Organization Model

[](#organization-model)

The package provides a complete `Organization` model with the following attributes:

- **name**: Organization name
- **slug**: URL-friendly identifier (auto-generated)
- **type**: Organization type (company, nonprofit, etc.)
- **email**: Contact email
- **phone**: Contact phone number
- **address**: Physical address
- **website**: Website URL
- **description**: Organization description
- **owner**: Polymorphic relationship to owning model
- **is\_active**: Active status

### API Endpoints

[](#api-endpoints)

The package automatically registers these routes under `/api/organizations`:

```
GET    /api/organizations              # List organizations
POST   /api/organizations              # Create organization
GET    /api/organizations/{id}         # Show organization
PUT    /api/organizations/{id}         # Update organization
DELETE /api/organizations/{id}         # Delete organization

```

### Workspace Integration

[](#workspace-integration)

When workspace scoping is enabled, organizations are automatically filtered by workspace:

```
GET    /api/workspaces/{id}/organizations    # Workspace-scoped organizations
POST   /api/workspaces/{id}/organizations    # Create in workspace

```

### Using in Your Models

[](#using-in-your-models)

```
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Whilesmart\Organizations\Models\Organization;

class Project extends Model
{
    public function organization(): BelongsTo
    {
        return $this->belongsTo(Organization::class);
    }
}
```

### Creating Organizations

[](#creating-organizations)

```
use Whilesmart\Organizations\Models\Organization;

$organization = Organization::create([
    'name' => 'Acme Corporation',
    'type' => 'company',
    'email' => 'contact@acme.com',
    'website' => 'https://acme.com',
    'owner_type' => 'App\Models\User',
    'owner_id' => $user->id,
    'is_active' => true,
]);
```

### Role-Based Access Control

[](#role-based-access-control)

The package integrates with `whilesmart/eloquent-roles` for permission management:

```
// Check if user can manage organizations
$user->hasPermission('manage-organizations');

// Check within specific workspace context
$user->hasPermission('manage-organizations', 'workspace', $workspaceId);
```

Configuration
-------------

[](#configuration)

The default configuration includes:

```
return [
    'workspace_scoped' => true,  // Enable workspace-level scoping
    'require_owner' => true,     // Organizations must have an owner
    'auto_slug' => true,         // Auto-generate slugs from names
];
```

Requirements
------------

[](#requirements)

- PHP ^8.2
- Laravel ^11.0|^12.0
- whilesmart/eloquent-roles ^1.0

Suggested Packages
------------------

[](#suggested-packages)

- **whilesmart/eloquent-workspaces**: For workspace integration support

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance96

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.4% 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 ~152 days

Total

3

Last Release

18d 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 (11 commits)")[![kofimokome](https://avatars.githubusercontent.com/u/21100923?v=4)](https://github.com/kofimokome "kofimokome (10 commits)")

---

Tags

phplaravelpackageorganization

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k38.9M150](/packages/darkaonline-l5-swagger)[creasi/laravel-nusa

A Laravel package that aim to provide Indonesia' Administrative Data

1008.3k3](/packages/creasi-laravel-nusa)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1422.0k5](/packages/team-nifty-gmbh-tall-datatables)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.8k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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