You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Model;
use App\Scopes\CommonPromoteScopes;
use App\Scopes\PlayerRoleScopes;
use App\Helper\DeviceType;
class PlayerRole extends Model
{
use CommonPromoteScopes;
use PlayerRoleScopes;
protected $table = 'tab_user_play_info';
public $timestamps = false;
public function promote()
{
return $this->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);
}
}