id(); $table->foreignId('company_id')->constrained()->onDelete('cascade'); $table->string('entity')->default('company'); // company, individual (person) $table->string('type'); // vendor, customer, employee $table->string('name'); $table->string('email')->nullable(); $table->string('tax_number')->nullable(); $table->string('phone')->nullable(); $table->text('address')->nullable(); $table->string('city')->nullable(); $table->string('zip_code')->nullable(); $table->string('state')->nullable(); $table->string('country')->nullable(); $table->string('website')->nullable(); $table->string('currency_code')->default('USD'); $table->string('reference')->nullable(); $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete(); $table->timestamps(); $table->index(['company_id', 'type']); $table->unique(['company_id', 'type', 'email']); $table->foreign('currency_code')->references('code')->on('currencies')->restrictOnDelete(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('contacts'); } };