*/ use HasFactory; public const SOURCE_SIGN_IN = 'sign_in'; /** * 允许批量赋值的字段。 * * @var array */ protected $fillable = [ 'user_id', 'source', 'badge_code', 'badge_name', 'badge_icon', 'badge_color', 'acquired_at', 'expires_at', 'is_active', 'metadata', ]; /** * 属性类型转换。 * * @return array */ protected function casts(): array { return [ 'acquired_at' => 'datetime', 'expires_at' => 'datetime', 'is_active' => 'boolean', 'metadata' => 'array', ]; } /** * 关联:身份徽章所属用户。 */ public function user(): BelongsTo { return $this->belongsTo(User::class); } }