id(); $t->foreignId('company_id')->constrained()->cascadeOnDelete(); $t->foreignId('plan_id')->nullable()->constrained()->nullOnDelete(); $t->enum('period', ['monthly', 'yearly'])->default('monthly'); $t->decimal('amount', 10, 2); $t->string('currency', 3)->default('MDL'); $t->enum('status', ['pending', 'paid', 'overdue', 'cancelled', 'refunded']) ->default('pending'); $t->date('period_start'); $t->date('period_end'); $t->timestamp('paid_at')->nullable(); $t->timestamp('due_at')->nullable(); $t->string('invoice_number', 30)->nullable(); $t->string('payment_method', 30)->nullable(); // card, bank_transfer, cash $t->string('reference', 100)->nullable(); // Stripe id, transfer ref $t->text('notes')->nullable(); $t->timestamps(); $t->index(['company_id', 'status']); $t->index('due_at'); $t->index('paid_at'); }); } public function down(): void { Schema::dropIfExists('subscriptions'); } };