37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\UserPaymentOptionStatus;
|
|
use App\Models\PaymentOption;
|
|
use App\Models\User;
|
|
use App\Models\UserPaymentOption;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<UserPaymentOption>
|
|
*/
|
|
class UserPaymentOptionFactory extends Factory
|
|
{
|
|
/**
|
|
* Define the model's default state.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'payment_option_id' => PaymentOption::factory(),
|
|
'status' => fake()->randomElement(UserPaymentOptionStatus::cases())->value,
|
|
'grandfathered_until' => fake()->optional()->dateTimeBetween('now', '+2 years'),
|
|
'legacy_conditions' => fake()->boolean(25)
|
|
? ['note' => fake()->sentence(), 'discount_percent' => fake()->numberBetween(5, 40)]
|
|
: null,
|
|
'current_period_start' => now()->startOfMonth(),
|
|
'current_period_end' => now()->endOfMonth(),
|
|
'stripe_subscription_id' => fake()->optional()->regexify('sub_[A-Za-z0-9]{14}'),
|
|
'cancelled_at' => null,
|
|
];
|
|
}
|
|
}
|