Added Device and UserIp models and migrations to store device fingerprints and user IPs with expiration. Updated ShowSavingIp Livewire component and view to capture and persist both IP and device fingerprint. Introduced a scheduled command to clean expired user IPs and registered it in the console kernel. Removed the old migration for storing IPs directly on the users table.
27 lines
633 B
PHP
27 lines
633 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
Schema::create('devices', function (Blueprint $table) {
|
|
$table->id();
|
|
|
|
$table->foreignId('user_id')->nullable()->constrained()->onDelete('cascade');
|
|
$table->string('fingerprint')->unique();
|
|
$table->timestamp('last_seen_at')->nullable();
|
|
|
|
$table->timestamps();
|
|
});
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('devices');
|
|
}
|
|
};
|