You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.3 KiB
62 lines
1.3 KiB
5 years ago
|
<?php
|
||
|
|
||
|
namespace app\models;
|
||
|
|
||
|
use Yii;
|
||
|
|
||
|
/**
|
||
|
* This is the model class for table "{{%user_form_id}}".
|
||
|
*
|
||
|
* @property integer $id
|
||
|
* @property integer $user_id
|
||
|
* @property string $form_id
|
||
|
* @property integer $times
|
||
|
* @property integer $addtime
|
||
|
*/
|
||
|
class UserFormId extends \yii\db\ActiveRecord
|
||
|
{
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public static function tableName()
|
||
|
{
|
||
|
return '{{%user_form_id}}';
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public function rules()
|
||
|
{
|
||
|
return [
|
||
|
[['user_id', 'form_id'], 'required'],
|
||
|
[['user_id', 'times', 'addtime'], 'integer'],
|
||
|
[['form_id'], 'string', 'max' => 255],
|
||
|
];
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
public function attributeLabels()
|
||
|
{
|
||
|
return [
|
||
|
'id' => 'ID',
|
||
|
'user_id' => 'User ID',
|
||
|
'form_id' => 'Form ID',
|
||
|
'times' => '剩余使用次数',
|
||
|
'addtime' => 'Addtime',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public static function saveFormId($args)
|
||
|
{
|
||
|
$m = new UserFormId();
|
||
|
$m->user_id = $args['user_id'];
|
||
|
$m->form_id = $args['form_id'];
|
||
|
$m->times = isset($args['times']) ? $args['times'] : 1;
|
||
|
$m->addtime = time();
|
||
|
$m->save();
|
||
|
}
|
||
|
}
|