PHPackages                             inmanturbo/laravel-delegator - 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. inmanturbo/laravel-delegator

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

inmanturbo/laravel-delegator
============================

This is my package laravel-delegator

v1.0.1(3y ago)112[2 PRs](https://github.com/inmanturbo/laravel-delegator/pulls)MITPHPPHP ^8.1

Since Mar 26Pushed 2y ago1 watchersCompare

[ Source](https://github.com/inmanturbo/laravel-delegator)[ Packagist](https://packagist.org/packages/inmanturbo/laravel-delegator)[ Docs](https://github.com/inmanturbo/laravel-delegator)[ RSS](/packages/inmanturbo-laravel-delegator/feed)WikiDiscussions main Synced yesterday

READMEChangelog (2)Dependencies (16)Versions (5)Used By (0)

For when you need to make some config changes when switching instances on a model, or when you need to track which instance of a model class is currently being used
====================================================================================================================================================================

[](#for-when-you-need-to-make-some-config-changes-when-switching-instances-on-a-model-or-when-you-need-to-track-which-instance-of-a-model-class-is-currently-being-used)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fe92607475c0ef54f61f585c6b9964b51606d766ddd07d377640fa0092eeb3a5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696e6d616e747572626f2f6c61726176656c2d64656c656761746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/inmanturbo/laravel-delegator)[![GitHub Tests Action Status](https://github.com/inmanturbo/laravel-delegator/actions/workflows/run-tests.yml/badge.svg)](https://github.com/inmanturbo/laravel-delegator/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://github.com/inmanturbo/laravel-delegator/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/inmanturbo/laravel-delegator/actions/workflows/fix-php-code-style-issues.yml)[![Total Downloads](https://camo.githubusercontent.com/9af4fd37d59c9d0c521aa10527906cd64e2fa68dbab32ef9830f161badc7bfc7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696e6d616e747572626f2f6c61726176656c2d64656c656761746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/inmanturbo/laravel-delegator)

Similar to [spatie/laravel-multitenancy](https://github.com/spatie/laravel-multitenancy), however this package doesn't limit you to a single model class, or "tenant".
You can have a database model like `App\Models\TeamDatabase` or `App\Models\AppDatabase` that dynamically sets some config values (and any other action) when changed for the request, for example. And/or You can also do stuff when switching users, or when switching teams, etc.

Support us
----------

[](#support-us)

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

[](#installation)

You can install the package via composer:

```
composer require inmanturbo/laravel-delegator
```

You can publish the config file with:

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

This is the contents of the published config file:

```
return [

    /*
     * The connection name to reach the delegator database
     */
    'delegator_database_connection_name' => null,

    'candidates' => [

        // 'team' => [

        //     /*
        //     * This class is responsible for determining which candidate should be current
        //     * for the given request.
        //     *
        //     * This class must implement the `Inmanturbo\Delegator\CandidateFinder\Contracts\CandidateFinder` interface.
        //     *
        //     */
        //     'candidate_finder' => null,

        //     /*
        //     * These fields are used by candidates:artisan command to match one or more tenant
        //     */
        //     'candidate_artisan_search_fields' => [
        //         'id',
        //     ],

        //     /*
        //     * These tasks will be performed when switching candidates.
        //     *
        //     * A valid task is any class that implements the `Inmanturbo\Delegator\Tasks\Contractstractstracts\SwitchCandidateTask` interface.
        //     */
        //     'switch_candidate_tasks' => [
        //         \Inmanturbo\Delegator\Tasks\SwitchCandidateConfigTask::class,
        //     ],

        //     /*
        //     * This class is the model used for storing configuration on candidates.
        //     *
        //     * It must implemement the `Inmanturbo\Delegator\Models\Contracts\CandidateModel` interface.
        //     */
        //     'model' => \App\Models\Team::class,

        //     /*
        //     * The connection name to reach the candidate database.
        //     *
        //     * Set to `null` to use the default connection.
        //     */
        //     'candidate_database_connection_name' => null,

        //     /*
        //     * This key will be used to bind the current candidate in the container.
        //     */
        //     'current_candidate_container_key' => 'currentTeam',

        //     /*
        //     * You can customize some of the behavior of this package by using your own custom action.
        //     * Your custom action should always extend the default one.
        //     */
        //     'actions' => [
        //         'make_current_action' => \Inmanturbo\Delegator\Actions\MakeCandidateCurrentAction::class,
        //         'forget_current_action' => \Inmanturbo\Delegator\Actions\ForgetCandidateCurrentAction::class,
        //         'migrate_action' => \Inmanturbo\Delegator\Actions\MigrateCandidateAction::class,
        //     ],
        // ],
    ],
];
```

Usage
-----

[](#usage)

First publish the config then uncomment the first `candidate` in the `candidates` array and fill in your correct values.

You can use any model that implements the `Inmanturbo\Delegator\Models\Contracts\CandidateModel` interface.

You can use the trait `Inmanturbo\Delegator\Models\Concerns\HasCandidateMethods`, or write your own methods to satisfy the interface.

### Making a candidate Current

[](#making-a-candidate-current)

```
$candidate = App\Models\Team::first(); // makeCurrent();
```

The above will execute the `config('delegator.candidates.team.actions.make_current_action')` which will call `makeCurrent()` on all of the tasks listed under `config('delegator.candidates.team.actions.switch_candidate_tasks')`

You can use these tasks to change or set config keys and values, start a lawn mower, etc.

Calling `makeCurrent()` on another instance of the model of the same class will first execute `config('delegator.candidates.team.actions.forget_current_action')` which calls `forgetCurrent()` on all of the same tasks.

You can do this with as many model classes as you want by adding their configurations to the `candidates` array in the `delegator` config file.
Each class will be tracked seperately, so you can have multiple current models of different types, but only one at a time of each type.

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.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [inmanturbo](https://github.com/inmanturbo)
- [All Contributors](../../contributors)
- This package was heavily inspired by [spatie/laravel-multitenancy](https://github.com/spatie/laravel-multitenancy)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.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 ~0 days

Total

2

Last Release

1196d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0261babef618b8fb3bfcea84376ed5e71e7169586eb8de63a6550c2e7ea653a6?d=identicon)[inmanturbo](/maintainers/inmanturbo)

---

Top Contributors

[![inmanturbo](https://avatars.githubusercontent.com/u/47095624?v=4)](https://github.com/inmanturbo "inmanturbo (25 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

laravelinmanturbolaravel-delegator

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/inmanturbo-laravel-delegator/health.svg)

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

###  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)
