use App\Models\User;
/**
* Indicate that the user should have a subscription plan.
*
* @return $this
*/
public function withSubscription(string|int $priceId = null): static
{
return $this->afterCreating(function (User $user) use ($priceId) {
optional($user->customer)->update(['trial_ends_at' => null]);
$subscription = $user->subscriptions()->create([
'type' => 'default',
'paddle_id' => fake()->unique()->numberBetween(1, 1000),
'status' => 'active',
'trial_ends_at' => null,
'paused_at' => null,
'ends_at' => null,
]);
$subscription->items()->create([
'product_id' => fake()->unique()->numberBetween(1, 1000),
'price_id' => $priceId,
'status' => 'active',
'quantity' => 1,
]);
});
}