41 lines
970 B
PHP
41 lines
970 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 文件功能:用户身份徽章测试工厂。
|
||
|
|
*
|
||
|
|
* 用于测试中快速构造签到来源或其他来源的身份徽章。
|
||
|
|
*/
|
||
|
|
|
||
|
|
namespace Database\Factories;
|
||
|
|
|
||
|
|
use App\Models\User;
|
||
|
|
use App\Models\UserIdentityBadge;
|
||
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @extends Factory<UserIdentityBadge>
|
||
|
|
*/
|
||
|
|
class UserIdentityBadgeFactory extends Factory
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 定义默认身份徽章测试数据。
|
||
|
|
*
|
||
|
|
* @return array<string, mixed>
|
||
|
|
*/
|
||
|
|
public function definition(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'user_id' => User::factory(),
|
||
|
|
'source' => UserIdentityBadge::SOURCE_SIGN_IN,
|
||
|
|
'badge_code' => 'sign_in_beginner',
|
||
|
|
'badge_name' => '签到新星',
|
||
|
|
'badge_icon' => null,
|
||
|
|
'badge_color' => '#0f766e',
|
||
|
|
'acquired_at' => now(),
|
||
|
|
'expires_at' => null,
|
||
|
|
'is_active' => true,
|
||
|
|
'metadata' => [],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|