the browser-facing portion of osu!
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\Multiplayer;
9
10use App\Models\Chat\Channel;
11use App\Models\Multiplayer\Room;
12use App\Models\User;
13use Carbon\Carbon;
14use Database\Factories\Factory;
15
16class RoomFactory extends Factory
17{
18 protected $model = Room::class;
19
20 public function configure(): static
21 {
22 return $this->afterCreating(function (Room $room) {
23 $channel = Channel::createMultiplayer($room);
24
25 $room->update(['channel_id' => $channel->getKey()]);
26 });
27 }
28
29 public function definition(): array
30 {
31 return [
32 'user_id' => User::factory(),
33 'name' => fn() => $this->faker->realText(20),
34 'starts_at' => fn() => Carbon::now()->subHours(1),
35 'ends_at' => fn() => Carbon::now()->addHours(1),
36 ];
37 }
38
39 public function ended(): static
40 {
41 return $this->state(['ends_at' => Carbon::now()->subMinutes(1)]);
42 }
43}