update save response req

This commit is contained in:
2020-09-24 10:30:52 +07:00
parent aade992cf9
commit db801e7d96
6 changed files with 71 additions and 22 deletions

60
models/ResponseReq.php Normal file
View File

@@ -0,0 +1,60 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "response_req".
*
* @property int $id
* @property string $content
* @property int $time
*/
class ResponseReq extends \yii\db\ActiveRecord {
/**
* {@inheritdoc}
*/
public static function tableName() {
return 'response_req';
}
/**
* {@inheritdoc}
*/
public function rules() {
return [
[['content', 'time'], 'required'],
[['content'], 'string'],
[['time'], 'integer'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels() {
return [
'id' => 'ID',
'content' => 'Content',
'time' => 'Time',
];
}
public function create($data) {
$r = $this->load([
'content' => json_encode($data),
'time' => time()
], '');
if ($r) {
try {
$this->save();
return $this->id;
} catch (\Exception $ex) {
return false;
}
}
}
}