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\ScorePin;
11use App\Models\Solo;
12use App\Models\User;
13
14class ScorePinFactory extends Factory
15{
16 protected $model = ScorePin::class;
17
18 public function definition(): array
19 {
20 return [
21 'user_id' => User::factory(),
22 'display_order' => rand(-1000, 1000),
23 ];
24 }
25
26 public function withScore(Solo\Score $score): static
27 {
28 return $this
29 ->state([
30 'ruleset_id' => $score->ruleset_id,
31 'user_id' => $score->user,
32 ])->for($score, 'score');
33 }
34}