You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2023_05_23_141215_create_documents_table.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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('documents', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->string('type'); // invoice, bill
  16. $table->string('document_number');
  17. $table->string('order_number')->nullable();
  18. $table->string('status');
  19. $table->dateTime('document_date');
  20. $table->dateTime('due_date');
  21. $table->dateTime('paid_date')->nullable();
  22. $table->decimal('amount', 15, 4);
  23. $table->foreignId('tax_id')->nullable()->constrained()->nullOnDelete();
  24. $table->foreignId('discount_id')->nullable()->constrained()->nullOnDelete();
  25. $table->string('reference')->nullable();
  26. $table->string('currency_code')->default('USD');
  27. $table->foreignId('category_id')->default(1)->constrained()->restrictOnDelete();
  28. $table->foreignId('contact_id')->nullable()->constrained()->nullOnDelete();
  29. $table->text('notes')->nullable();
  30. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  31. $table->timestamps();
  32. $table->foreign('currency_code')->references('code')->on('currencies')->restrictOnDelete();
  33. });
  34. }
  35. /**
  36. * Reverse the migrations.
  37. */
  38. public function down(): void
  39. {
  40. Schema::dropIfExists('documents');
  41. }
  42. };