1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6declare(strict_types=1);
7
8namespace Database\Factories\Store;
9
10use App\Models\Store\Order;
11use App\Models\User;
12use Carbon\Carbon;
13use Database\Factories\Factory;
14
15class OrderFactory extends Factory
16{
17 protected $model = Order::class;
18
19 public function checkout(): static
20 {
21 return $this->state(['status' => 'checkout']);
22 }
23
24 public function definition(): array
25 {
26 return [
27 'user_id' => User::factory(),
28 ];
29 }
30
31 public function paid(): static
32 {
33 $date = Carbon::now();
34
35 return $this->state([
36 'paid_at' => $date,
37 'status' => 'paid',
38 'transaction_id' => "test-{$date->timestamp}",
39 ]);
40 }
41
42 public function incart(): static
43 {
44 return $this->state(['status' => 'incart']);
45 }
46
47 public function processing(): static
48 {
49 return $this->state(['status' => 'processing']);
50 }
51
52 public function shipped(): static
53 {
54 return $this->state(['status' => 'shipped']);
55 }
56
57 public function shopify(): static
58 {
59 return $this->state([
60 // Doesn't need to be a gid for tests.
61 'transaction_id' => Order::PROVIDER_SHOPIFY.'-'.time(),
62 ]);
63 }
64}