POINT_CURRENCY_TYPE::class, 'display_attributes' => PointCurrencyDisplayAttributesCast::class, ]; /** * 根据类型获取积分类型配置 * * @param int $type 积分类型 * @return PointCurrencyModel|null 积分类型模型 */ public static function getByType(int $type): ?PointCurrencyModel { return self::where('type', $type)->first(); } /** * 根据标识获取积分类型配置 * * @param string $identification 积分标识 * @return PointCurrencyModel|null 积分类型模型 */ public static function getByIdentification(string $identification): ?PointCurrencyModel { return self::where('identification', $identification)->first(); } /** * 获取所有积分类型 * * @return \Illuminate\Database\Eloquent\Collection 积分类型集合 */ public static function getAllCurrencies() { return self::orderBy('type')->get(); } /** * 检查积分类型是否存在 * * @param int $type 积分类型 * @return bool 是否存在 */ public static function typeExists(int $type): bool { return self::where('type', $type)->exists(); } /** * 检查积分标识是否存在 * * @param string $identification 积分标识 * @return bool 是否存在 */ public static function identificationExists(string $identification): bool { return self::where('identification', $identification)->exists(); } /** * 获取积分类型名称 * * @return string 积分类型名称 */ public function getCurrencyName(): string { return $this->type->getCurrencyName(); } /** * 获取积分类型标识 * * @return string 积分类型标识 */ public function getIdentification(): string { return $this->type->getIdentification(); } /** * 获取积分类型描述 * * @return string 积分类型描述 */ public function getDescription(): string { return $this->type->getDescription(); } /** * 获取积分类型图标 * * @return string 积分类型图标 */ public function getTypeIcon(): string { return $this->type->getIcon(); } /** * 关联积分配置表 */ public function configs() { return $this->hasMany(PointConfigModel::class, 'currency_id'); } }