PHPackages                             whilesmart/laravel-user-devices - 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. whilesmart/laravel-user-devices

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

whilesmart/laravel-user-devices
===============================

Package for managing user devices across our projects

v1.0.1(3mo ago)0724[1 PRs](https://github.com/whilesmartphp/laravel-user-devices/pulls)MITPHPCI passing

Since Jul 5Pushed 2mo agoCompare

[ Source](https://github.com/whilesmartphp/laravel-user-devices)[ Packagist](https://packagist.org/packages/whilesmart/laravel-user-devices)[ RSS](/packages/whilesmart-laravel-user-devices/feed)WikiDiscussions dev Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (15)Used By (0)

Whilesmart Laravel User Devices Package
=======================================

[](#whilesmart-laravel--user-devices-package)

This Laravel package provides a complete devices solution ready to be integrated into your application.

Features
--------

[](#features)

- **Ready-to-use devices endpoints:**
- **OpenAPI documentation:** Automatically generated documentation using PHP attributes.
- **Configuration file:** Easily customize settings.
- **Laravel agnostic considerations:** designed with future framework agnosticism in mind.

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

[](#installation)

### 1. Require the package

[](#1-require-the-package)

```
composer require whilesmart/laravel-user-devices
```

### 2. Publish the configuration and migrations:

[](#2-publish-the-configuration-and-migrations)

You do not need to publish the migrations and configurations except if you want to make modifications. You can choose to publish the migrations, routes, controllers separately or all at once.

#### 2.1 Publishing only the routes

[](#21-publishing-only-the-routes)

Run the command below to publish only the routes.

```
php artisan vendor:publish --tag=user-devices-routes
php artisan migrate
```

The routes will be available at `routes/user-devices.php`. You should `require` this file in your `api.php`file.

```
    require 'user-devices.php';
```

#### 2.2 Publishing only the migrations

[](#22-publishing-only-the-migrations)

+If you would like to make changes to the migration files, run the command below to publish only the migrations.

```
php artisan vendor:publish --tag=laravel-user-devices-migrations
php artisan migrate
```

The migrations will be available in the `database/migrations` folder.

#### 2.3 Publish only the controllers

[](#23-publish-only-the-controllers)

By default the controllers assign the device to the currently logged in user. If you would like to assign the device to another model, you can publish the controllers and make the necessary changes to the published file.
To publish the controllers, run the command below

```
php artisan vendor:publish --tag=laravel-user-devices-controllers
php artisan migrate
```

The controllers will be available in the `app/Http/Controllers` directory. Finally, change the namespace in the published controllers to your namespace.

#### Note: Publishing the controllers will also publish the routes. See section 2.1

[](#note-publishing-the-controllers-will-also-publish-the-routes-see-section-21)

#### 2.4 Publish the config

[](#24-publish--the-config)

To publish the config, run the command below

```
php artisan vendor:publish --tag=laravel-user-devices-config
```

The config file will be available in the `config/user-devices.php`. The config file has the folowing variables:

- `register_routes`: Default `true`. Auto registers the routes. If you do not want to auto-register the routes, set the value to `false
- `route_prefix`: Default `api`. Defines the prefix for the auto-registered routes.
- `db_table_name`: Default `devices`. Defines the name of the database table to create.

#### 2.5 Publish OpenAPI Documentations

[](#25-publish-openapi-documentations)

```
php artisan vendor:publish --tag=laravel-user-devices-docs
```

The documentation will be available in the `app/Http/Interfaces` directory.

#### 2.6 Publish Locals

[](#26-publish-locals)

```
php artisan vendor:publish --tag=laravel-user-devices-locals
```

The locales will be available in the `resources/lang//devices.php`.

#### 2.7 Publish everything

[](#27-publish-everything)

To publish the migrations, routes and controllers, you can run the command below

```
php artisan vendor:publish --tag=laravel-user-devices
php artisan migrate
```

#### Note: See section 2.1 above to make the routes accessible

[](#note-see-section-21-above-to-make-the-routes-accessible)

### 3. Model Relationships

[](#3-model-relationships)

We have implemented a Trait `HasDevices` that handles relationships. If your model has devices, simply use the `HasDevices` trait in your model definition.

```
use Whilesmart\UserDevices\Traits\HasDevices
class MyModel {
 use HasDevices;
}

```

You can call `yourModel->devices()` to get the list of devices tied to the model

```
$model = new MyModel();
$model->devices();
```

The `HasDevices` trait also has the `getDevicesAttribute()` method. If you want to append the devices to the model response, simply add `devices` to your model's $appends

```
use Whilesmart\UserDevices\Traits\HasDevices;
class MyModel {
 use HasDevices;

 protected $appends = ['devices'];
}
```

Usage
-----

[](#usage)

After installation, the following API endpoints will be available:

- **POST /api/devices:** Registers a new device linked to the current logged in user.
- **Get /api/devices:** Retrieves all devices linked to the current logged in user.
- **PUT /api/devices/{id}:** Updates the device information.
- **DELETE /api/devices/{id}:** Deletes a device from the database.
- **OpenAPI Documentation:** Accessible via a route that your OpenAPI package defines.

**Example Registration Request:**

```
{
  "token":"unique_token_string",
  "name":"Chrome on Windows",
  "type":"web",
  "identifier":"device_identifier",
  "platform":"Windows"
}
```

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance83

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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 ~181 days

Total

2

Last Release

104d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1ca6f6e01ecbfe6640ff410c4f0321054fb48d05a5f843c2b89887b90369bcd?d=identicon)[whilesmart](/maintainers/whilesmart)

---

Top Contributors

[![kofimokome](https://avatars.githubusercontent.com/u/21100923?v=4)](https://github.com/kofimokome "kofimokome (14 commits)")[![nfebe](https://avatars.githubusercontent.com/u/14317775?v=4)](https://github.com/nfebe "nfebe (4 commits)")

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/whilesmart-laravel-user-devices/health.svg)

```
[![Health](https://phpackages.com/badges/whilesmart-laravel-user-devices/health.svg)](https://phpackages.com/packages/whilesmart-laravel-user-devices)
```

###  Alternatives

[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[laravel-ready/license-server

License server for Laravel

1271.2k](/packages/laravel-ready-license-server)

PHPackages © 2026

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