-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathPluginLicenseFactory.php
More file actions
63 lines (56 loc) · 1.54 KB
/
PluginLicenseFactory.php
File metadata and controls
63 lines (56 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Database\Factories;
use App\Models\Plugin;
use App\Models\PluginLicense;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<PluginLicense>
*/
class PluginLicenseFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'user_id' => User::factory(),
'plugin_id' => Plugin::factory(),
'stripe_payment_intent_id' => 'pi_'.$this->faker->uuid(),
'price_paid' => $this->faker->numberBetween(1000, 10000),
'currency' => 'USD',
'is_grandfathered' => false,
'purchased_at' => now(),
'expires_at' => null,
];
}
public function expired(): static
{
return $this->state(fn (array $attributes) => [
'expires_at' => now()->subDay(),
]);
}
public function expiresIn(int $days): static
{
return $this->state(fn (array $attributes) => [
'expires_at' => now()->addDays($days),
]);
}
public function grandfathered(): static
{
return $this->state(fn (array $attributes) => [
'is_grandfathered' => true,
]);
}
public function refunded(): static
{
return $this->state(fn (array $attributes) => [
'refunded_at' => now(),
'stripe_refund_id' => 're_'.$this->faker->uuid(),
'refunded_by' => User::factory(),
]);
}
}