Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

2024_11_19_225812_create_addresses_table.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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('addresses', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->foreignId('parent_address_id')->nullable()->constrained('addresses')->nullOnDelete();
  16. $table->morphs('addressable');
  17. $table->string('type'); // billing, shipping, etc.
  18. $table->string('recipient')->nullable();
  19. $table->string('phone')->nullable();
  20. $table->string('address_line_1')->nullable();
  21. $table->string('address_line_2')->nullable();
  22. $table->string('city')->nullable();
  23. $table->smallInteger('state_id')->nullable();
  24. $table->string('postal_code')->nullable();
  25. $table->string('country_code');
  26. $table->text('notes')->nullable();
  27. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  28. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  29. $table->timestamps();
  30. });
  31. }
  32. /**
  33. * Reverse the migrations.
  34. */
  35. public function down(): void
  36. {
  37. Schema::dropIfExists('addresses');
  38. }
  39. };