'Save as Guest with IP and lat lng in Locations table and After User Registration associate user to location table permanently
I created Location Table with IP, Lat , Lng and Address Columns for guest. My Goal is to save unknown visitor value in location Table with their unique system IP address. Once the visitor register and become permanent user I want that user associate with location table permanently. Later on he can change the location whenever he want.
is this better approach I am bit confuse about the logics please suggest how can I accomplish this task?
User Table
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique()->nullable();
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->string('photo')->nullable();
$table->enum('role',['admin','seller','rider','customer'])->default('customer');
$table->string('provider')->nullable();
$table->string('provider_id')->nullable();
$table->enum('status',['active','inactive'])->default('active');
$table->rememberToken()->nullable();
$table->timestamps();
});
}
Guest Location Table
public function up()
{
Schema::create('locations', function (Blueprint $table) {
$table->id();
$table->string('ip')->unique();
$table->string('lat');
$table->string('lng');
$table->string('faddress');
$table->unsignedBigInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL');
$table->timestamps();
});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
