Download the PHP package litepie/organization without Composer
On this page you can find all versions of the php package litepie/organization. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download litepie/organization
More information about litepie/organization
Files in litepie/organization
Package organization
Short Description A Laravel package for managing organizational hierarchy with single table structure
License MIT
Homepage https://github.com/litepie/organization
Informations about the package organization
Organization Hierarchy Package
A Laravel 12 package for managing organizational hierarchy using a single table structure with support for companies, branches, departments, divisions, and sub-divisions. The package includes built-in multi-tenant support for SaaS applications.
Requirements
- PHP 8.2+
- Laravel 12.0+
- MySQL 8.0+ / PostgreSQL 13+ / SQLite 3.35+
Features
- ✅ Laravel 12 compatible with modern PHP features
- 🏢 Single table organization hierarchy
- 🔄 Multiple organization types (company, branch, department, division, sub_division)
- 👤 Manager assignment with primary and secondary managers
- 👥 User role assignments within organizations
- 🌳 Recursive tree operations with optimized queries
- 🔐 Policy-based authorization with Laravel Gates
- 📡 Event-driven architecture with modern event broadcasting
- 🌐 Comprehensive API and web controllers
- 🏗️ Multi-tenant support with configurable tenant resolution
- 🎯 Enhanced type safety with PHP 8.2+ features
Installation
Install the package via Composer:
For multi-tenant applications, also install the Litepie Tenancy package:
Publish and run the migrations:
Publish the configuration file:
Configuration
The configuration file config/organization.php
allows you to customize:
- Organization types
- Status options
- User model reference
- Route prefixes
- Middleware settings
- Multi-tenant integration
Multi-Tenant Setup
This package integrates seamlessly with the Litepie\Tenancy package for multi-tenant applications.
-
Install Litepie Tenancy:
-
Enable tenancy in organization config:
-
Configure tenancy package:
- Add tenant-aware middleware to routes:
How Multi-Tenancy Works
When tenancy is enabled:
- Organizations are automatically scoped to the current tenant using the
BelongsToTenant
trait - All queries are filtered by the current tenant's ID
- New organizations are automatically assigned to the current tenant
- The
tenant_id
column is added to the organizations table
Tenant Detection
The package uses Litepie\Tenancy's flexible tenant detection:
Usage
Basic CRUD Operations
Multi-Tenant Operations
When multi-tenancy is enabled, organizations are automatically scoped to the current tenant:
Working with Multiple Tenants
Querying by Type
Working with Hierarchy
Manager Assignment
User Trait
Add the HasOrganization
trait to your User model:
Then use it:
API Endpoints
The package provides RESTful API endpoints:
GET /api/organizations
- List organizationsPOST /api/organizations
- Create organizationGET /api/organizations/{id}
- Show organizationPUT /api/organizations/{id}
- Update organizationDELETE /api/organizations/{id}
- Delete organizationGET /api/organizations/tree
- Get organization treePOST /api/organizations/{id}/managers
- Assign managerDELETE /api/organizations/{id}/managers/{userId}
- Remove manager
Events
The package fires the following events:
OrganizationCreated
OrganizationUpdated
OrganizationDeleted
ManagerAssigned
ManagerRemoved
Testing
Run the tests:
License
This package is open-sourced software licensed under the MIT license.
All versions of organization with dependencies
illuminate/support Version ^12.0
illuminate/database Version ^12.0
illuminate/events Version ^12.0
illuminate/validation Version ^12.0
litepie/tenancy Version ^1.0