-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Since the device_uuid is persistent per device, if two accounts are accessed from the same device, an error occurrs due to duplicate tokens in the devices table.
Solution 1
Use a composite key (token, deviceable_id, deviceable_type) to uniquely identify a device
Solution 2
Use a pivot table to solve this problem. The proposed schema for the pivot table is shown below
Schema::create('device_assignments', function (Blueprint $table) {
$table->id();
$table->foreignId('device_id')->constrained()->onDelete('cascade');
$table->morphs('deviceable'); // deviceable_id + deviceable_type
$table->timestamps();
$table->unique(['device_id', 'deviceable_id', 'deviceable_type']); // avoid duplicates
});the package can provide a way to link a device to any other model via assignments
Metadata
Metadata
Assignees
Labels
No labels