Pharaonic
Loading...

OLD VERSION

WARNING : You're browsing the documentation for an old version of Users. Consider upgrading your project to 2.x

# Inclusion

This is how you can include devices in the user model.

1namespace App\Models;
2 
3use Pharaonic\Laravel\Users\Traits\HasDevices;
4 
5class User extends Authenticatable
6{
7 use HasDevices;
8}

# devices

Getting list of Devices (Agents) List.

1$devices = $user->devices;
2// Returns Illuminate\Database\Eloquent\Collection

# fcmList

Getting list of devices FCM (Firebase Cloud Messaging).

1$fcmList = $user->fcmList;
2// Returns Array|null

# currentDeviceSignature

Getting signature of the current device.

1$signature = $user->currentDeviceSignature;
2// Returns String
3// Example : d16616d7-2db5-4863-be6a-de3fc1460806-nTJTGTJIdU0wWqQy

# currentDevice

Getting the current device object.

1$device = $user->currentDevice;
2// Returns Pharaonic\Laravel\Users\Models\UserAgent|null

# hasDetectedDevice

Check if the current device has been detected or not.

1if($user->hasDetectedDevice()) {
2 //
3}

# detectDevice

Detect the current user device and store info in database.

1$user->detectDevice($fcm);
2// $fcm (OPTIONAL) Firebase Cloud Messaging Token
3// Returns Pharaonic\Laravel\Users\Models\UserAgent Model

# removeDevice

Remove a device with the signature.

1$user->removeDevice($signature);
2// Returns boolean

# removeAllDevices

Remove all devices.

1$user->removeAllDevices();
2// Returns boolean