Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

2023_05_19_042232_create_contacts_table.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('contacts', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->onDelete('cascade');
  15. $table->string('entity')->default('company'); // company, individual (person)
  16. $table->string('type'); // vendor, customer, employee
  17. $table->string('name');
  18. $table->string('email')->nullable();
  19. $table->string('tax_number')->nullable();
  20. $table->string('phone')->nullable();
  21. $table->text('address')->nullable();
  22. $table->string('city')->nullable();
  23. $table->string('zip_code')->nullable();
  24. $table->string('state')->nullable();
  25. $table->string('country')->nullable();
  26. $table->string('website')->nullable();
  27. $table->string('currency_code')->default('USD');
  28. $table->string('reference')->nullable();
  29. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  30. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  31. $table->timestamps();
  32. $table->index(['company_id', 'type']);
  33. $table->unique(['company_id', 'type', 'email']);
  34. $table->foreign('currency_code')->references('code')->on('currencies')->restrictOnDelete();
  35. });
  36. }
  37. /**
  38. * Reverse the migrations.
  39. */
  40. public function down(): void
  41. {
  42. Schema::dropIfExists('contacts');
  43. }
  44. };