*/ class RefundFactory extends Factory { protected $model = Refund::class; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'payment_id' => Payment::factory()->completed(), 'status' => RefundStatus::Pending, 'amount' => $this->faker->randomFloat(2, 1000, 50000), 'reason' => $this->faker->sentence(), 'gateway_refund_id' => null, 'gateway_payload' => null, 'requested_by' => null, 'requested_at' => now(), 'completed_at' => null, ]; } public function completed(): static { return $this->state(fn (array $attributes): array => [ 'status' => RefundStatus::Completed, 'completed_at' => now(), ]); } public function failed(): static { return $this->state(fn (array $attributes): array => [ 'status' => RefundStatus::Failed, 'completed_at' => now(), ]); } }