You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xshop/database/migrations/2024_06_09_134141_create_ad...

43 lines
1.3 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('addresses', function (Blueprint $table) {
$table->id();
$table->text('address');
$table->unsignedBigInteger('customer_id');
$table->double('lat')->nullable();
$table->double('lng')->nullable();
$table->unsignedBigInteger('state_id')->nullable()->default(null);
$table->unsignedBigInteger('city_id')->nullable()->default(null);
$table->json('data')->nullable();
$table->string('zip')->nullable()->comment('postal code');
$table->timestamps();
$table->softDeletes();
$table->foreign('customer_id')->references('id')
->on('customers')->onDelete('cascade');
$table->foreign('state_id')->references('id')
->on('states')->onDelete('cascade');
$table->foreign('city_id')->references('id')
->on('cities')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('addresses');
}
};