sfolador/devices

Manage mobile devices and tokens easily with Laravel
1,309 9
Install
composer require sfolador/devices
Latest Version:1.3
PHP:^8.1|^8.2|^8.3|^8.4
Laravel:10 · 11 · 12
License:MIT
Last Updated:Jun 17, 2026
Links: GitHub  ·  Packagist
Maintainer: sfolador

Manage mobile devices and tokens easily with Laravel

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Easily manage devices and device tokens for your users.

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

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

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

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

arcanedev/agent

A PHP user agent parser based on Mobiledetect.

786 1
christhompsontldr/fluxui-devices

FluxUI front-end for managing devices and sessions using diego-ninja/laravel-dev...

471 0
agenticmorf/fluxui-devices

FluxUI front-end for managing devices and sessions using diego-ninja/laravel-dev...

102 0
pijler/user-devices

This package provides support for managing user devices.

1,248 0
sfolador/measures-for-laravel

A collection of unit conversions utils for Laravel

11,724 10

Version History

Version Released PHP Laravel License
1.3 ^8.1|^8.2|^8.3|^8.4 ^10.0|^11.0|^12.0 MIT
1.2 ^8.1|^8.2|^8.3|^8.4 ^10.0|^11.0 MIT
1.1 ^8.1|^8.2|^8.3|^8.4 ^10.0|^11.0 MIT
1.0 ^8.1|^8.2|^8.3|^8.4 ^10.0|^11.0 MIT
0.6 ^8.1|^8.2|^8.3 ^10.0|^11.0 MIT