the browser-facing portion of osu!
at master 42 lines 1.1 kB view raw
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\User; 11use App\Models\UserDonation; 12 13class UserDonationFactory extends Factory 14{ 15 protected $model = UserDonation::class; 16 17 public function definition(): array 18 { 19 return [ 20 'amount' => 4, 21 'cancel' => false, 22 'length' => 1, 23 'transaction_id' => fn () => $this->transactionId(), 24 'user_id' => User::factory(), 25 26 'target_user_id' => fn (array $attr) => $attr['user_id'], 27 ]; 28 } 29 30 public function cancelled(): static 31 { 32 return $this->state([ 33 'cancel' => true, 34 'transaction_id' => fn () => "{$this->transactionId()}-cancel", 35 ]); 36 } 37 38 private function transactionId(): string 39 { 40 return 'faked-'.time().'-'.$this->faker->randomNumber(); 41 } 42}