您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

2024_11_27_223015_create_invoices_table.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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('invoices', function (Blueprint $table) {
  13. $table->id();
  14. $table->foreignId('company_id')->constrained()->cascadeOnDelete();
  15. $table->foreignId('client_id')->nullable()->constrained('clients')->nullOnDelete();
  16. $table->string('logo')->nullable();
  17. $table->string('header')->nullable();
  18. $table->string('subheader')->nullable();
  19. $table->string('invoice_number')->nullable();
  20. $table->string('order_number')->nullable(); // PO, SO, etc.
  21. $table->date('date')->nullable();
  22. $table->date('due_date')->nullable();
  23. $table->timestamp('approved_at')->nullable();
  24. $table->timestamp('paid_at')->nullable();
  25. $table->timestamp('last_sent')->nullable();
  26. $table->string('status')->default('draft');
  27. $table->string('currency_code')->nullable();
  28. $table->integer('subtotal')->default(0);
  29. $table->integer('tax_total')->default(0);
  30. $table->integer('discount_total')->default(0);
  31. $table->integer('total')->default(0);
  32. $table->integer('amount_paid')->default(0);
  33. $table->integer('amount_due')->storedAs('total - amount_paid');
  34. $table->text('terms')->nullable(); // terms, notes
  35. $table->text('footer')->nullable();
  36. $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
  37. $table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
  38. $table->timestamps();
  39. });
  40. }
  41. /**
  42. * Reverse the migrations.
  43. */
  44. public function down(): void
  45. {
  46. Schema::dropIfExists('invoices');
  47. }
  48. };