2024_05_26_171707_create_countries_table.php
Schema::create('countries', function (Blueprint $table) {
$table->string('code', 3)->primary();
$table->string('name', 255);
$table->jsonb('states')->nullable();
});
2024_05_26_171822_create_customer_addresses_table.php
Schema::create('customer_addresses', function (Blueprint $table) {
$table->id();
$table->foreignId('customer_id')->constrained('customers');
$table->string('type', 45);
$table->string('address1', 255);
$table->string('address2', 255);
$table->string('city', 255);
$table->string('state', 45)->nullable();
$table->string('zipcode', 45);
$table->string('country_code', 3);
$table->foreign('country_code')->references('code')->on('countries');
$table->timestamps();
});
customer_addresses
de
$table->foreignId('country_code')->constrained('countries');
constrained
olarak nasıl kullanabilirim.