PHPackages                             ahs12/laravel-setanjo - 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. ahs12/laravel-setanjo

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

ahs12/laravel-setanjo
=====================

Laravel settings package for managing application configurations, user preferences, feature flags, and A/B testing with multi-tenant support

1.0.0(1y ago)8512[5 PRs](https://github.com/AHS12/laravel-setanjo/pulls)MITPHPPHP ^8.2CI passing

Since Jun 12Pushed 5mo agoCompare

[ Source](https://github.com/AHS12/laravel-setanjo)[ Packagist](https://packagist.org/packages/ahs12/laravel-setanjo)[ Docs](https://github.com/ahs12/laravel-setanjo)[ GitHub Sponsors](https://github.com/AHS12)[ RSS](/packages/ahs12-laravel-setanjo/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (4)Dependencies (13)Versions (11)Used By (0)

laravel-setanjo - Laravel Settings Package with Multi-Tenant Support
====================================================================

[](#laravel-setanjo---laravel-settings-package-with-multi-tenant-support)

[![Build Status](https://github.com/ahs12/laravel-setanjo/actions/workflows/run-tests.yml/badge.svg)](https://github.com/ahs12/laravel-setanjo/actions)[![Total Downloads](https://camo.githubusercontent.com/d38e2a47816df52a0bef91be95beba9e08face9957400c22bb94dc5cee499758/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61687331322f6c61726176656c2d736574616e6a6f)](https://packagist.org/packages/ahs12/laravel-setanjo)[![Latest Stable Version](https://camo.githubusercontent.com/ab7bcae8fc9ec66bf1f0ea48b1893126022aefef6ba28697d076d2c2f868fed4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61687331322f6c61726176656c2d736574616e6a6f)](https://packagist.org/packages/ahs12/laravel-setanjo)[![License](https://camo.githubusercontent.com/64982cde5a7e872b17c56f307998d366e8b210e0785e4c02caeb463266d2b31e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61687331322f6c61726176656c2d736574616e6a6f)](https://packagist.org/packages/ahs12/laravel-setanjo)

A powerful Laravel package for managing application settings and configurations. Store global application settings or model-specific configurations (user preferences, company settings, etc.) with automatic type casting, caching, and a clean API. Perfect for feature flags, A/B testing, user preferences, and dynamic configuration management.

**Note**: This package does **not** provide multi-tenancy features for your application. However, if your Laravel project already has multi-tenancy implemented, this package can store tenant-specific settings alongside your existing tenant architecture.

Features
--------

[](#features)

- 🏢 **Multi-Tenant Ready**: Works with existing multi-tenant applications
- 🗃️ **Model-Specific Settings**: Store settings for any Eloquent model (User, Company, etc.)
- 🏛️ **Global Settings**: Application-wide settings without model scope
- ⚡ **Caching**: Optional caching with configurable cache store
- 🔒 **Validation**: Validate models and prevent unauthorized access
- 📦 **Clean API**: Simple, intuitive API for setting and retrieving values
- 🧪 **Fully Tested**: Comprehensive test suite included
- ✅ **Type Safety**: Automatic type detection and conversion

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

[](#requirements)

- PHP 8.2 or higher
- Laravel 10.0 or higher

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

[](#installation)

1. **Install the package:**

```
composer require ahs12/laravel-setanjo
```

2. **Publish and run migrations:**

```
php artisan vendor:publish --tag="setanjo-migrations"
php artisan migrate
```

3. **Configure tenancy mode (optional):**

By default, the package runs in **strict mode** (single tenant model type).

For basic setup with User model, no configuration needed. For other models or multiple tenant types:

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

Quick Setup
-----------

[](#quick-setup)

### Option 1: Strict Mode (Default - Single Tenant Type)

[](#option-1-strict-mode-default---single-tenant-type)

Perfect for simple user preferences or single-model tenancy:

```
// Uses App\Models\User by default
// No configuration needed
```

### Option 2: Custom Strict Mode

[](#option-2-custom-strict-mode)

For using a different model as the single tenant type:

```
// config/setanjo.php
'tenancy_mode' => 'strict',
'strict_tenant_model' => App\Models\Company::class,
```

### Option 3: Polymorphic Mode

[](#option-3-polymorphic-mode)

For multiple tenant model types (SaaS apps, complex multi-tenancy):

```
// config/setanjo.php
'tenancy_mode' => 'polymorphic',
'allowed_tenant_models' => [
    App\Models\User::class,
    App\Models\Company::class,
    App\Models\Organization::class,
],
```

Basic Usage
-----------

[](#basic-usage)

### Global Settings

[](#global-settings)

```
use Ahs12\Setanjo\Facades\Settings;

// Set application-wide settings
Settings::set('app_name', 'My Application');
Settings::set('maintenance_mode', false);

// Get with default fallback
$appName = Settings::get('app_name', 'Default Name');
```

### Tenant Settings (Strict Mode)

[](#tenant-settings-strict-mode)

```
// User-specific settings (default tenant model)
$user = User::find(1);
Settings::for($user)->set('theme', 'dark');
Settings::for($user)->set('language', 'en');

// Or by tenant ID
Settings::forTenantId(1)->set('notifications', true);

echo Settings::for($user)->get('theme'); // 'dark'
```

### Tenant Settings (Polymorphic Mode)

[](#tenant-settings-polymorphic-mode)

```
// Different model types as tenants
$user = User::find(1);
$company = Company::find(1);

Settings::for($user)->set('theme', 'dark');
Settings::for($company)->set('timezone', 'UTC');

// Or by tenant ID with model class
Settings::forTenantId(1, Company::class)->set('currency', 'USD');
```

### Type Casting

[](#type-casting)

```
Settings::set('is_active', true);        // Boolean
Settings::set('max_users', 100);         // Integer
Settings::set('rate', 4.99);             // Float
Settings::set('features', ['api', 'sms']); // Array
Settings::set('config', '{"theme": "dark", "lang": "en"}'); // JSON string
Settings::set('metadata',['version' => '1.0', 'author' => 'John']); // Object

// Values are returned with correct types
$isActive = Settings::get('is_active'); // Returns boolean true
$maxUsers = Settings::get('max_users'); // Returns integer 100
$rate = Settings::get('rate');          // Returns float 4.99
$features = Settings::get('features');  // Returns array ['api', 'sms']
$config = Settings::get('config');      // Returns array ['theme' => 'dark', 'lang' => 'en']
$metadata = Settings::get('metadata');  // Returns object with version and author properties
```

Common Use Cases
----------------

[](#common-use-cases)

### User Preferences

[](#user-preferences)

```
$user = auth()->user();
Settings::for($user)->set('notification_email', true);
Settings::for($user)->set('dashboard_layout', 'grid');
Settings::for($user)->set('timezone', 'America/New_York');
```

### Application Configuration

[](#application-configuration)

```
Settings::set('maintenance_mode', false);
Settings::set('registration_enabled', true);
Settings::set('api_rate_limit', 1000);
```

### Multi-Tenant SaaS (Polymorphic Mode)

[](#multi-tenant-saas-polymorphic-mode)

```
// Company-level settings
Settings::for($company)->set('feature_api_enabled', true);
Settings::for($company)->set('user_limit', 50);

// User preferences within company
Settings::for($user)->set('email_notifications', false);
```

Documentation
-------------

[](#documentation)

For detailed documentation, advanced usage, and configuration options, visit our [documentation site](https://github.com/ahs12/laravel-setanjo/wiki).

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance60

Regular maintenance activity

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.9% 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 ~0 days

Total

4

Last Release

385d ago

Major Versions

0.0.3 → 1.0.02025-06-14

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25058208?v=4)[Azizul Hakim](/maintainers/AHS12)[@AHS12](https://github.com/AHS12)

---

Top Contributors

[![AHS12](https://avatars.githubusercontent.com/u/25058208?v=4)](https://github.com/AHS12 "AHS12 (31 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

abtestingexperimentslaravel-packagemulti-tenantsettingslaravelconfigurationSettingsmulti-tenantfeature-flagsab-testingpolymorphicuser-preferences

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/ahs12-laravel-setanjo/health.svg)

```
[![Health](https://phpackages.com/badges/ahs12-laravel-setanjo/health.svg)](https://phpackages.com/packages/ahs12-laravel-setanjo)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)

PHPackages © 2026

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