POINT_TYPE::class, 'display_attributes' => PointDisplayAttributesCast::class, ]; /** * 获取积分类型配置 * * @param int $pointType 积分类型 * @return PointConfigModel|null 配置模型 */ public static function getByType(int $pointType): ?PointConfigModel { return self::where('type', $pointType)->first(); } /** * 获取所有积分配置 * * @return \Illuminate\Database\Eloquent\Collection 配置集合 */ public static function getAllConfigs() { return self::orderBy('type')->get(); } /** * 根据积分类型ID获取配置 * * @param int $currencyId 积分类型ID * @return \Illuminate\Database\Eloquent\Collection 配置集合 */ public static function getByCurrencyId(int $currencyId) { return self::where('currency_id', $currencyId)->get(); } /** * 检查积分类型是否存在 * * @param int $pointType 积分类型 * @return bool 是否存在 */ public static function typeExists(int $pointType): bool { return self::where('type', $pointType)->exists(); } /** * 获取积分类型名称 * * @return string 积分类型名称 */ public function getTypeName(): string { return $this->type->getTypeName(); } /** * 获取积分类型描述 * * @return string 积分类型描述 */ public function getTypeDescription(): string { return $this->type->getDescription(); } /** * 关联积分类型表 */ public function currency() { return $this->belongsTo(PointCurrencyModel::class, 'currency_id'); } }