generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Tenancy Modes
Azizul Hakim edited this page Jun 12, 2025
·
1 revision
Understanding the difference between strict and polymorphic tenancy modes.
Perfect for simple applications with a single tenant model type.
// config/setanjo.php
'tenancy_mode' => 'strict',
'strict_tenant_model' => App\Models\User::class,$user = User::find(1);
Settings::for($user)->set('theme', 'dark');
// By ID (model class is inferred)
Settings::forTenantId(1)->set('language', 'en');- User preferences applications
- Simple multi-user systems
- Single tenant model type scenarios
For complex applications with multiple tenant model types.
// config/setanjo.php
'tenancy_mode' => 'polymorphic',
'allowed_tenant_models' => [
App\Models\User::class,
App\Models\Company::class,
App\Models\Organization::class,
],$user = User::find(1);
$company = Company::find(1);
Settings::for($user)->set('theme', 'dark');
Settings::for($company)->set('plan', 'enterprise');
// By ID (model class required)
Settings::forTenantId(1, User::class)->set('language', 'en');
Settings::forTenantId(1, Company::class)->set('billing_cycle', 'monthly');- SaaS applications
- Multi-level tenancy (users + organizations)
- Complex business hierarchies
- Update configuration
- Add new models to
allowed_tenant_models - Existing data remains compatible
- Ensure only one model type has settings
- Update configuration
- Consider data migration if needed
Made with ❤️ by @AHS12 • © 2025 • MIT Licensed
- Home - Homepage of the wiki
- Installation Guide - Set up Setanjo in your Laravel project
- Setup & Configuration - Configure tenancy modes and basic options
- Quick Start Examples - Get up and running in minutes
- Tenancy Modes - Understanding strict vs polymorphic modes
- Facade API Reference - Complete method documentation
- HasSettings Trait - Uses of HasSrttings trait
- Commands - Artisan commands for management
- Performance Tips - Optimization best practices