···11+<?php
22+33+// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
44+// See the LICENCE file in the repository root for full licence text.
55+66+declare(strict_types=1);
77+88+namespace Database\Factories;
99+1010+use App\Models\User;
1111+use App\Models\UsernameChangeHistory;
1212+use Carbon\Carbon;
1313+1414+class UsernameChangeHistoryFactory extends Factory
1515+{
1616+ protected $model = UsernameChangeHistory::class;
1717+1818+ public function definition(): array
1919+ {
2020+ return [
2121+ 'timestamp' => Carbon::now(),
2222+ 'type' => 'paid',
2323+ 'user_id' => User::factory(),
2424+2525+ // depend on user_id; the username will be incorrect when factorying multiple names at once,
2626+ // so they should be handled separately if realistic name changes are wanted.
2727+ 'username' => fn (array $attr) => User::find($attr['user_id'])->username,
2828+ 'username_last' => fn (array $attr) => "{$attr['username']}_prev",
2929+ ];
3030+ }
3131+}