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
6namespace Database\Factories;
7
8use App\Models\Build;
9use Carbon\Carbon;
10
11class BuildFactory extends Factory
12{
13 protected $model = Build::class;
14
15 public function definition(): array
16 {
17 return [
18 'date' => fn () => $this->faker->dateTimeBetween('-5 years'),
19 'hash' => fn () => md5(rand(), true),
20 'stream_id' => fn () => array_rand_val($GLOBALS['cfg']['osu']['changelog']['update_streams']),
21 'users' => rand(100, 10000),
22
23 // the default depends on date
24 'version' => fn (array $attr) => (
25 isset($attr['date'])
26 ? Carbon::instance($attr['date'])->format('Ymd')
27 : null
28 ),
29 ];
30 }
31}