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;
9
10use App\Models\Contest;
11use Carbon\Carbon;
12
13class ContestFactory extends Factory
14{
15 protected $model = Contest::class;
16
17 public function completed(): static
18 {
19 return $this->state([
20 'entry_starts_at' => fn() => Carbon::now()->subMonths(4),
21 'entry_ends_at' => fn() => Carbon::now()->subMonths(3),
22 'voting_starts_at' => fn() => Carbon::now()->subMonths(2),
23 'voting_ends_at' => fn() => Carbon::now()->subMonths(1),
24 ]);
25 }
26
27 public function definition(): array
28 {
29 return [
30 'name' => fn() => $this->faker->sentence(),
31 'description_enter' => fn() => $this->faker->paragraph(),
32 'description_voting' => fn() => $this->faker->paragraph(),
33 'type' => 'art',
34 'header_url' => '/images/headers/generic.jpg',
35 'visible' => 1,
36 ];
37 }
38
39 public function entry(): static
40 {
41 return $this->state([
42 'entry_starts_at' => fn() => Carbon::now()->subMonths(1),
43 'entry_ends_at' => fn() => Carbon::now()->addMonths(1),
44 'voting_starts_at' => fn() => Carbon::now()->addMonths(2),
45 'voting_ends_at' => fn() => Carbon::now()->addMonths(3),
46 ]);
47 }
48
49 public function judged(): static
50 {
51 return $this->state([
52 'extra_options' => ['judged' => true],
53 ]);
54 }
55
56 public function pending(): static
57 {
58 return $this->state([
59 'entry_starts_at' => fn() => Carbon::now()->addMonths(1),
60 'entry_ends_at' => fn() => Carbon::now()->addMonths(2),
61 'voting_starts_at' => fn() => Carbon::now()->addMonths(3),
62 'voting_ends_at' => fn() => Carbon::now()->addMonths(4),
63 ]);
64 }
65
66 public function voting(): static
67 {
68 return $this->state([
69 'entry_starts_at' => fn() => Carbon::now()->subMonths(3),
70 'entry_ends_at' => fn() => Carbon::now()->subMonths(2),
71 'voting_starts_at' => fn() => Carbon::now()->subMonths(1),
72 'voting_ends_at' => fn() => Carbon::now()->addMonths(1),
73 ]);
74 }
75}