PHPackages                             aldeebhasan/multi-agents - 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. aldeebhasan/multi-agents

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

aldeebhasan/multi-agents
========================

This package will help you to handle multi device operations

1.0.0(4y ago)211MITPHP

Since Dec 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/aldeebhasan/multi-agents)[ Packagist](https://packagist.org/packages/aldeebhasan/multi-agents)[ RSS](/packages/aldeebhasan-multi-agents/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Multi Agent Library
===================

[](#multi-agent-library)

A php package that enable the user to handle multiple agent (devices) at the same time. This package allows you to link any model with many devices, and provide a kind of authentication for the functionality this device can use.

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

[](#installation)

Install using composer:

```
composer require aldeebhasan/multi-agents
```

After finishing the installation process you need to migrate the package tables to the database. run the following command

```
php artisan migrate
```

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

[](#basic-usage)

### Devices

[](#devices)

To identify that any specific model could be linked with various devices, you can use the `HasMultiAgent` trait.

```
class Client
{
    use HasMultiAgent;
    ...
```

To create a new device you can use the `register` function. **Note:** `uuid` should be unique for each device

```
$device = Device::register('uuid');
```

Now, you can use the following functions to link/unlink the device with the `Client` model

```
use Aldeebhasan\MultiAgents\Models\Device

$device = Device::register('uuid');
$client = new Client();

// Link the device with the model
$client->linkDevices($device);

//you can also pass a list of device objects
$client->linkDevices([$device,$device,....]);

// Unlink the device from the model
$client->unlinkDevices($device);

//you can also pass a list of device objects
$client->unlinkDevices([$device,$device,....]);

//unlink all the devices related to specific model
$client->unlinkAll();
```

To retrieve all te devices lined to specific model

```
$client->devices
```

To obtain the owner of the device use the following.

**Note:** The owner could be any model use the `HasMultiAgent` trait, and the device already linked to it.

```
$device->owner
```

Finally, thanks for the [Agent](https://github.com/jenssegers/agent) package author, where you can perform a list of check functions over the current device agent. yYou can check all the function related to the device egent from [here](https://github.com/jenssegers/agent).

Now, to retrieve the device agent object you can use.

```
$device = $client->devices->first();
$device->agent
```

### Middleware

[](#middleware)

After registering any device, the device object will have a `token` attribute. This attribute should be sent at the `Header` or as `POST`or `GET` parameter with the key `Device-Token` to authenticate this registered device.

To use the device authentication middleware, you need to add it first to the `app\Http\Kernel.php` under `$routeMiddleware` as follow:

```
'auth.device' => \Aldeebhasan\MultiAgents\Middleware\DeviceAuthenticated::class,
```

Next, you have to attach the middleware to your rout or inside your controller.

```
//in the routes
Route::middleware(['auth.device'])->group(function () {
    Route::get('/device-info', function () {
        return getCurrentDevice();
    });
});
//in the controller
 public function __construct()
    {
        $this->middleware('auth.device';
    }
```

The package contains `getCurrentDevice()` helper function to retrieve the device that match the passed `Device-Token`

Furthermore, if you want to authenticate only the devices linked with a specific model, you can pass the Model class name to the middleware.

```
// if the passed token match with any of the token
// registered for the `Client` model it wil allow
// it to pass to the inner route.
// Otherwise, DeviceAuthenticationException Exception will be thrown
Route::middleware(['auth.device:'.Client::class])->group(function () {
    Route::get('/device-info', function () {
        return getCurrentDevice();
    });
});
```

### Exceptions

[](#exceptions)

Two kinds of exceptions could be thrown from the package DeviceAuthenticated middleware:

- **DeviceAuthenticationException**: when no device match the passed token.
- **DeviceExpiredTokenException**: when the device token is expired and the device need to be registered again.

### Settings

[](#settings)

Each device could have a list of setting related to it.

You can initialize a list of settings you want to link with a specific set of devices, and attach them to the devices.

```
use Aldeebhasan\MultiAgents\Models\Setting

$setting1 = Setting::register('key1');
$setting2 = Setting::register('key2');
//add settings with its value to specific device
$device->addSettings([
            'key1'=>'value1',
            'key2'=>'value2',
        ]);
//remove setting/s from a specific device
//single setting
$device->deleteSettings('key1');
//multiple settings
$device->deleteSettings(['key1','key2']);

//to perform the two operations togather and sync the settings with their value with specific device
$device2->syncSettings([
         'key1'=>'value1',
        ]);
//the sync function will unlink all the settings doesn't much the keys,
// and link/change the  value of the settings that are appeared in the  provided list
```

Finally, to retrive all the setting related to specific device

```
$device->getSettings();
//output: [
//    'key1'=>'value1',
//    'key2'=>'value2',
//  ]
```

License
-------

[](#license)

Laravel Multi Agent package is licensed under [The MIT License (MIT)](https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt).

Security contact information
----------------------------

[](#security-contact-information)

To report a security vulnerability, contact directly to the developer contact email [Here](mailto:aldeeb.91@gmail.com).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

1616d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/74e7b9d93b0f666f462ad0be43dde05991e9d141f9fe840009775808107d440e?d=identicon)[aldeebhasan](/maintainers/aldeebhasan)

---

Tags

agent-managmentdevices-managerlaravelmulti-devicesettings-managementlaravelagentsmulti-agentsmulti-devices

### Embed Badge

![Health badge](/badges/aldeebhasan-multi-agents/health.svg)

```
[![Health](https://phpackages.com/badges/aldeebhasan-multi-agents/health.svg)](https://phpackages.com/packages/aldeebhasan-multi-agents)
```

###  Alternatives

[mischasigtermans/laravel-altitude

Claude Code agents for the TALL stack, powered by Laravel Boost

1139.2k](/packages/mischasigtermans-laravel-altitude)[anilcancakir/laravel-ai-sdk-skills

A skill system for Laravel AI SDK agents. Define reusable AI capabilities with SKILL.md files.

151.1k](/packages/anilcancakir-laravel-ai-sdk-skills)[cleaniquecoders/shrinkr

Shrinkr is a Laravel package for shortening URLs, with custom slugs, analytics, branded domains, and seamless API integration.

142.9k](/packages/cleaniquecoders-shrinkr)

PHPackages © 2026

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