*/ class InvoiceFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { $amount = fake()->numberBetween(1000, 20000); $tax = (int) round($amount * 0.19); return [ 'user_id' => User::factory(), 'user_payment_id' => UserPayment::factory(), 'invoice_billing_address_id' => InvoiceBillingAddress::factory(), 'number' => now()->format('Ym').'-'.fake()->unique()->numerify('####'), 'status' => fake()->randomElement(InvoiceStatus::cases())->value, 'amount_cents' => $amount, 'tax_cents' => $tax, 'total_cents' => $amount + $tax, 'currency' => 'EUR', 'is_netto' => false, 'invoice_date' => now()->toDateString(), 'due_date' => now()->addDays(14)->toDateString(), 'paid_at' => null, 'stripe_invoice_id' => fake()->optional()->regexify('in_[A-Za-z0-9]{14}'), 'pdf_path' => null, ]; } }