A comprehensive Laravel package for implementing organization-based tenancy in your application. This package provides a complete solution for managing organizations, user memberships, roles, and automatic data scoping with SOLID principles compliance.
- 🏢 Organization Management - Complete CRUD operations with UUID and slug support
- 👥 User Membership - Flexible role-based membership system with administrators and members
- 🔒 Automatic Data Scoping - Seamless multi-tenancy through Eloquent global scopes
- ⚙️ Comprehensive Settings - Extensive JSON-based configuration system with validation
- 🧩 SOLID Principles - Contract-based architecture for flexibility and testability
- 🛠️ Developer Friendly - Built-in factories, commands, and trait-based integration
composer require cleaniquecoders/laravel-organization
php artisan vendor:publish --tag="org-migrations"
php artisan migrate
use CleaniqueCoders\LaravelOrganization\Actions\CreateNewOrganization;
use CleaniqueCoders\LaravelOrganization\Enums\OrganizationRole;
// Create an organization
$organization = (new CreateNewOrganization())->handle($user);
// Add members
$organization->addUser($user, OrganizationRole::ADMINISTRATOR);
$organization->addUser($member, OrganizationRole::MEMBER);
// Configure settings
$organization->setSetting('app.timezone', 'America/New_York');
$organization->setSetting('features.api_access', true);
$organization->save();
use CleaniqueCoders\LaravelOrganization\Concerns\InteractsWithUserOrganization;
use CleaniqueCoders\LaravelOrganization\Contracts\UserOrganizationContract;
class User extends Authenticatable implements UserOrganizationContract
{
use InteractsWithUserOrganization;
protected $fillable = ['name', 'email', 'password', 'organization_id'];
}
// Now you can:
$user->organizations; // Get all user's organizations
$user->currentOrganization; // Get current organization
$user->ownedOrganizations; // Get organizations user owns
$user->belongsToOrganization($id); // Check membership
$user->isAdministratorOf($id); // Check admin role
Comprehensive documentation is available in the docs/
directory:
- 📖 Installation Guide - Detailed setup instructions
- 🚀 Usage Guide - Complete usage examples and patterns
- ⚙️ Configuration - All configuration options and customization
- 🎯 Features Overview - Complete feature breakdown
- 🔧 Contracts Documentation - SOLID principles and custom implementations
- 🧩 Components & Actions - Livewire components and action classes
- PHP 8.4+
- Laravel 11.0+ or 12.0+
composer test
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.