42 lines
936 B
PHP
42 lines
936 B
PHP
<?php
|
|
namespace common\models\forms;
|
|
|
|
use common\core\BaseModel;
|
|
use common\enums\UserRoleEnum;
|
|
use common\models\oldDb\ImMessageSession;
|
|
use yii\base\Exception;
|
|
|
|
class ImSessionForm extends BaseModel
|
|
{
|
|
public $user_id;
|
|
public $service_id;
|
|
public $type;
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['user_id','service_id'],'required'],
|
|
['type','default','value'=>UserRoleEnum::DOCTOR],//默认医生会话
|
|
];
|
|
}
|
|
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'user_id' => '用户端id',
|
|
'service_id' => '服务端id',
|
|
];
|
|
}
|
|
|
|
//创建会话
|
|
public function session()
|
|
{
|
|
if (!$this->validate()) {
|
|
throw new Exception($this->getErrorMsg());
|
|
}
|
|
$ims = new ImMessageSession();
|
|
$ims->attributes = $this->attributes;
|
|
$ims->saveOrFail();
|
|
return $ims;
|
|
}
|
|
} |