| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace addons\ShortVideo\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "{{%addons_short_video_browse}}".
- *
- * @property int $id
- * @property int $mall_id
- * @property int $video_id 视频id
- * @property int $user_id 用户id
- * @property int $is_share 是否分享观看 0:否 1:是
- * @property int $is_complete_look 是否完整观看0:否 1:是
- * @property int $complete_time 完整观看时间
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at
- * @property int $updated_at
- */
- class ShortVideoBrowse extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_short_video_browse}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'video_id', 'user_id'], 'required'],
- [['mall_id', 'video_id', 'user_id', 'is_share', 'is_complete_look', 'complete_time', 'status', 'created_at', 'updated_at'], 'integer'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城ID',
- 'video_id' => '视频ID',
- 'user_id' => '会员ID',
- 'is_share' => '是否分享观看',
- 'is_complete_look' => '是否完整观看',
- 'complete_time' => '完整观看时间',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => 'Created At',
- 'updated_at' => 'Updated At',
- ];
- }
- public static function setData(int $mall_id, array $data)
- {
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $mall_id;
- foreach ($data as $key => $val) {
- $model->$key = $val;
- }
- // dd($model);
- if (!$model->save()) {
- self::$static_error = '保存数据失败:' . $model->getErrorMessage();
- return false;
- }
- return $model;
- }
- }
|