find(); if(empty($self)){ return []; } return $self->toArray(); } public static function getAll() { return self::where('id', '>', 0)->order('sort', 'desc')->select(); } /** * @desc 判断国家码是否存在 * @param $code * @return bool * @throws \think\db\exception\DbException */ public static function checkCodeExists($code): bool { $count = self::where('code', $code)->count(); return $count > 0; } public static function getNameById($id, $lang = 'en') { $self = self::where('id', $id)->find(); if(empty($self)){ return ''; } if($lang == 'cn'){ return $self->name_cn; } return $self->name_en; } }