*/ class DelayedGoodFactory extends Factory { /** * Define the model's default state. * * @return array */ public function definition(): array { $quantity = fake()->numberBetween(1, 100); $unitPrice = fake()->numberBetween(5000, 20000); $totalAmount = $quantity * $unitPrice; $isPaid = fake()->boolean(); $paidAmount = $isPaid ? $totalAmount : fake()->numberBetween(0, $totalAmount); $storedDate = fake()->dateTimeBetween('-1 month', 'now'); return [ 'customer_id' => Customer::factory(), 'unit_id' => Unit::factory(), 'quantity' => $quantity, 'unit_price' => $unitPrice, 'total_amount' => $totalAmount, 'paid_amount' => $paidAmount, 'stored_date' => $storedDate, 'is_paid' => $isPaid, 'payment_date' => $isPaid ? fake()->dateTimeBetween($storedDate, 'now') : null, 'notes' => fake()->optional()->sentence(), ]; } }