canyin-project/ybcy/models/common/MiniAuth.php
2024-11-01 16:07:54 +08:00

46 lines
1.1 KiB
PHP

<?php
namespace app\models\common;
use Yii;
use yii\db\ActiveRecord;
class MiniAuth extends ActiveRecord{
public static function tableName()
{
return "{{%ybwm_mini_auth}}";
}
public function rules()
{
return [
[['authorizer_appid','authorizer_access_token','expires_in','authorizer_refresh_token'],'required'],
[['func_info','authorizer_info'],'safe']
];
}
public function beforeSave($insert)
{
parent::beforeSave($insert);
if(!empty($this->func_info)){
$this->func_info = json_encode($this->func_info,320);
}
if(!empty($this->authorizer_info)){
$this->authorizer_info = json_encode($this->authorizer_info,320);
}
return true;
}
public function afterFind()
{
parent::afterFind(); // TODO: Change the autogenerated stub
if(!empty($this->func_info)){
$this->func_info = json_decode($this->func_info,true);
}
if(!empty($this->authorizer_info)){
$this->authorizer_info = json_decode($this->authorizer_info,true);
}
return true;
}
}