{"id":37265274,"url":"https://github.com/aldeebhasan/multi-agents","last_synced_at":"2026-01-16T00:06:50.404Z","repository":{"id":56943933,"uuid":"437088077","full_name":"aldeebhasan/multi-agents","owner":"aldeebhasan","description":"This package will help you to handle multi device operations","archived":false,"fork":false,"pushed_at":"2021-12-11T19:27:51.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-23T05:48:21.085Z","etag":null,"topics":["agent-managment","devices-manager","laravel","multi-device","settings-management"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aldeebhasan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-10T19:11:15.000Z","updated_at":"2024-09-11T13:15:15.000Z","dependencies_parsed_at":"2022-08-21T07:50:47.244Z","dependency_job_id":null,"html_url":"https://github.com/aldeebhasan/multi-agents","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/aldeebhasan/multi-agents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldeebhasan%2Fmulti-agents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldeebhasan%2Fmulti-agents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldeebhasan%2Fmulti-agents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldeebhasan%2Fmulti-agents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aldeebhasan","download_url":"https://codeload.github.com/aldeebhasan/multi-agents/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldeebhasan%2Fmulti-agents/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent-managment","devices-manager","laravel","multi-device","settings-management"],"created_at":"2026-01-16T00:06:49.671Z","updated_at":"2026-01-16T00:06:50.381Z","avatar_url":"https://github.com/aldeebhasan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Multi Agent Library\n=====\nA php package that enable the user to handle multiple agent (devices) at the same time. This package allows you to link\nany model with many devices, and provide a kind of authentication for the functionality this device can use.\n\n\nInstallation\n------------\n\nInstall using composer:\n\n```bash\ncomposer require aldeebhasan/multi-agents\n```\nAfter finishing the installation process you need to migrate the package tables to the database.\nrun the following command\n```php\nphp artisan migrate\n```\n\n\nBasic Usage\n-----------\n\n### Devices\n\nTo identify that any specific model could be linked with various devices, you can use the `HasMultiAgent` trait.\n\n```php\nclass Client \n{\n    use HasMultiAgent;\n    ...\n```\n\nTo create a new device you can use the `register` function.\n\u003cb\u003eNote:\u003c/b\u003e `uuid` should be unique for each device\n\n```php\n$device = Device::register('uuid');\n```\n\nNow, you can use the following functions to link/unlink the device with the `Client` model\n\n```php\nuse Aldeebhasan\\MultiAgents\\Models\\Device\n\n$device = Device::register('uuid');\n$client = new Client();\n\n// Link the device with the model\n$client-\u003elinkDevices($device);\n\n//you can also pass a list of device objects\n$client-\u003elinkDevices([$device,$device,....]);\n\n// Unlink the device from the model\n$client-\u003eunlinkDevices($device);\n\n//you can also pass a list of device objects\n$client-\u003eunlinkDevices([$device,$device,....]);\n\n//unlink all the devices related to specific model\n$client-\u003eunlinkAll();\n```\n\nTo retrieve all te devices lined to specific model\n\n```php\n$client-\u003edevices\n```\nTo obtain the owner of the device use the following.\n\n\u003cb\u003eNote:\u003c/b\u003e The owner could be any model use the `HasMultiAgent` trait, and the device already linked to it.\n\n```php\n$device-\u003eowner\n```\n\nFinally, thanks for the [Agent](https://github.com/jenssegers/agent) package author, where you can perform a list of\ncheck functions over the current device agent. yYou can check all the function related to the device egent\nfrom [here](https://github.com/jenssegers/agent).\n\nNow, to retrieve the device agent object you can use.\n\n```php\n$device = $client-\u003edevices-\u003efirst();\n$device-\u003eagent\n```\n\n### Middleware\nAfter registering any device, the device object will have a `token` attribute.\nThis attribute should be sent at the `Header` or as `POST`or `GET` parameter with the key `Device-Token` to authenticate this registered device.\n\nTo use the device authentication middleware, you need to add it first to the `app\\Http\\Kernel.php` under `$routeMiddleware` as follow:\n```php\n'auth.device' =\u003e \\Aldeebhasan\\MultiAgents\\Middleware\\DeviceAuthenticated::class,\n```\nNext, you have to attach the middleware to your rout or inside your controller.\n```php\n//in the routes\nRoute::middleware(['auth.device'])-\u003egroup(function () {\n    Route::get('/device-info', function () {\n        return getCurrentDevice();\n    });\n});\n//in the controller\n public function __construct()\n    {\n        $this-\u003emiddleware('auth.device';\n    }\n```\nThe package contains `getCurrentDevice()` helper function to retrieve the device that match the passed `Device-Token`\n\nFurthermore, if you want to  authenticate only the devices linked with a specific model, you can pass the Model class name to the middleware.\n```php\n// if the passed token match with any of the token\n// registered for the `Client` model it wil allow\n// it to pass to the inner route.\n// Otherwise, DeviceAuthenticationException Exception will be thrown\nRoute::middleware(['auth.device:'.Client::class])-\u003egroup(function () {\n    Route::get('/device-info', function () {\n        return getCurrentDevice();\n    });\n});\n```\n### Exceptions\nTwo kinds of exceptions could be thrown from the package DeviceAuthenticated middleware:\n\n- **DeviceAuthenticationException**: when no device match the passed token.\n- **DeviceExpiredTokenException**: when the device token is expired and the device need to be registered again.\n\n### Settings\n\nEach device could have a list of setting related to it.\n\nYou can initialize a list of settings you want to link with a specific set of devices, and attach them to the devices.\n\n```php\nuse Aldeebhasan\\MultiAgents\\Models\\Setting\n\n$setting1 = Setting::register('key1');\n$setting2 = Setting::register('key2');\n//add settings with its value to specific device\n$device-\u003eaddSettings([\n            'key1'=\u003e'value1',\n            'key2'=\u003e'value2',\n        ]);\n//remove setting/s from a specific device\n//single setting\n$device-\u003edeleteSettings('key1'); \n//multiple settings\n$device-\u003edeleteSettings(['key1','key2']); \n\n//to perform the two operations togather and sync the settings with their value with specific device\n$device2-\u003esyncSettings([\n         'key1'=\u003e'value1',\n        ]);\n//the sync function will unlink all the settings doesn't much the keys,\n// and link/change the  value of the settings that are appeared in the  provided list\n\n```\n\nFinally, to retrive all the setting related to specific device\n\n```php\n$device-\u003egetSettings(); \n//output: [\n//    'key1'=\u003e'value1',\n//    'key2'=\u003e'value2',\n//  ]\n\n```\n\n\n## License\n\nLaravel Multi Agent package is licensed under [The MIT License (MIT)](https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt).\n\n## Security contact information\n\nTo report a security vulnerability, contact directly to the developer contact email [Here](mailto:aldeeb.91@gmail.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldeebhasan%2Fmulti-agents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faldeebhasan%2Fmulti-agents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldeebhasan%2Fmulti-agents/lists"}