PHPackages                             sfolador/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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. sfolador/devices

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

sfolador/devices
================

Manage mobile devices and tokens easily with Laravel

1.2(1y ago)81.1k2[4 PRs](https://github.com/sfolador/devices/pulls)MITPHPPHP ^8.1|^8.2|^8.3|^8.4CI passing

Since Feb 28Pushed 2mo ago1 watchersCompare

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

READMEChangelog (4)Dependencies (15)Versions (14)Used By (0)

[![](https://camo.githubusercontent.com/70571fdd8062b4f1d34fff7be5389ef9bf8754ffe50f59d00046f7a8b5b206f1/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f446576696365732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d73666f6c61646f7225324664657669636573267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4d616e6167652b646576696365732b616e642b6465766963652b746f6b656e732b266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d75706c6f6164)](https://camo.githubusercontent.com/70571fdd8062b4f1d34fff7be5389ef9bf8754ffe50f59d00046f7a8b5b206f1/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f446576696365732e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d73666f6c61646f7225324664657669636573267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d4d616e6167652b646576696365732b616e642b6465766963652b746f6b656e732b266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313030707826696d616765733d75706c6f6164)

Manage mobile devices and tokens easily with Laravel
====================================================

[](#manage-mobile-devices-and-tokens-easily-with-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ff3a9e2b3d3b22f370dc07c24b68dd4cd8c629fe9e541a2885fc6c2aae62d2e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73666f6c61646f722f646576696365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfolador/devices)[![GitHub Tests Action Status](https://camo.githubusercontent.com/03f0eea72ce5b9c133a2ff26413240bb7d847cd31d48cc030bb0f21898ff53a9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73666f6c61646f722f646576696365732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sfolador/devices/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/5a47de30628cd9c42f8379642bda212a0b3e9ddcd1ca9f2c9eeb9e5f23f4b7d8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73666f6c61646f722f646576696365732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/sfolador/devices/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3eddbd66b558b479fa3d1f9cd0705bb9d0937d7cf5d3f303f17c6bd20b686cf9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73666f6c61646f722f646576696365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sfolador/devices)

Easily manage devices and device tokens for your users.

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

[](#installation)

You can install the package via composer:

```
composer require sfolador/devices
```

You can publish the config file with:

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

This is the contents of the published config file:

```
return [
     'allow_device_reassign' => false,
];
```

if you set `allow_device_reassign` to true, it will be possible to register a device for a user and then assign it to another user. This happens usually in mobile applications with multi-accounts on the same device.

You can publish and run the migrations with:

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

the migration will create the `Devices` table and its columns will be:

- `id` - the device id
- `notifiable_id` - the "user" id
- `notifiable_type` - the "user" type
- `name` - the device name
- `type` - the device type (mobile, web)
- `platform` - the device platform (ios, android, web)
- `token` - the device token
- `created_at` - the device creation date
- `updated_at` - the device update date

Usage
-----

[](#usage)

It's possible to use the `HasDevices` trait in your `User` model:

```
use Sfolador\Devices\Models\Concerns\HasDevices;

class User extends Authenticatable
{
    use HasDevices;
}
```

At this point is possible to retrieve the devices of a user:

```
$user = User::find(1);
$user->devices;
```

To register a new `Device`, for example from a mobile app, you can use the provided route `POST /api/devices/attach`:

```
Route::post('/devices/attach', [DeviceController::class, 'attach']);
```

### Device parameters

[](#device-parameters)

The register a Device you need a request with these parameters:

```
$rules = [
    'platform' => ['required', new Enum(DevicePlatform::class)],
    'type' => ['required', new Enum(DeviceType::class)],
    'token' => 'required|string',
];
```

DevicePlatform is an Enum that can have these values: android, ios, web. DeviceType is an Enum that can have these values: mobile, web

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)

- [sfolador](https://github.com/sfolador)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance67

Regular maintenance activity

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 66.7% 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 ~86 days

Recently: every ~0 days

Total

9

Last Release

487d ago

Major Versions

0.6 → 1.02025-01-14

PHP version history (3 changes)0.1PHP ^8.1

0.2PHP ^8.1|^8.2|^8.3

1.0PHP ^8.1|^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/54c6b8884e3bd4e86d26de024ca07094728adc7db2a8a483538222121b00f9f1?d=identicon)[sfolador](/maintainers/sfolador)

---

Top Contributors

[![sfolador](https://avatars.githubusercontent.com/u/36632?v=4)](https://github.com/sfolador "sfolador (56 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (16 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")

---

Tags

deviceeasy-to-usefirebaselaravelpush-notificationstokenlaravelsfoladorDevices

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sfolador-devices/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)

PHPackages © 2026

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