belongsTo(Promote::class, 'promote_id', 'id'); } public function user() { return $this->belongsTo(User::class, 'user_id', 'id'); } public function testingBinding() { return $this->hasOne(TestingBinding::class, 'role_key', 'role_key'); } public function bindTestingBinding() { return $this->hasOne(TestingBinding::class, 'bind_role_key', 'role_key'); } public function getDeviceTypeNameAttribute() { return DeviceType::getDeviceTypeText($this->sdk_version); } public function getBaseGameNameAttribute() { return strtr($this->game_name, ['(安卓版)' => '', '(苹果版)' => '']); } public static function generateUniqueCode($gameId, $userId, $roleId) { if (is_null($roleId)) { $roleId = 'UNKNOW'; } return substr(md5($gameId . '#' . $userId . '#' . $roleId), 8, 16); } }