the browser-facing portion of osu!
at master 59 lines 1.6 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\Store; 9 10use App\Models\Store\Order; 11use App\Models\Store\OrderItem; 12use App\Models\Store\Product; 13use Database\Factories\Factory; 14 15class OrderItemFactory extends Factory 16{ 17 protected $model = OrderItem::class; 18 19 public function definition(): array 20 { 21 return [ 22 'cost' => 12.0, 23 'order_id' => Order::factory(), 24 'product_id' => Product::factory(), 25 'quantity' => 1, 26 ]; 27 } 28 29 public function reserved(): static 30 { 31 return $this->state(['reserved' => true]); 32 } 33 34 public function supporterTag(): static 35 { 36 return $this->state([ 37 'cost' => 4, 38 'extra_data' => function (array $attributes) { 39 $user = Order::find($attributes['order_id'])->user; 40 41 return [ 42 'duration' => 1, 43 'target_id' => (string) $user->getKey(), 44 'username' => $user->username, 45 ]; 46 }, 47 'product_id' => Product::customClass('supporter-tag')->first(), 48 ]); 49 } 50 51 public function usernameChange(): static 52 { 53 return $this->state([ 54 'cost' => 0, 55 'extra_info' => 'new_username', 56 'product_id' => Product::customClass('username-change')->first(), 57 ]); 58 } 59}