yii2-netdisk/models/CollectionUploaded.php

84 lines
2.2 KiB
PHP
Raw Permalink Normal View History

<?php
namespace app\models;
use yii\db\ActiveQuery;
2024-02-26 15:42:18 +08:00
use yii\db\ActiveRecord;
/**
* This is the model class for table "collection_uploaded".
*
* @property int $id 文件收集的上传记录id
2024-04-06 13:53:17 +08:00
* @property int|null $user_id 用户ID
* @property int $task_id 对应的文件收集id
* @property string $uploader_ip 上传者ip
* @property string $uploaded_at 上传时间
* @property string $subfolder_name 对应的子文件夹名
2024-04-06 13:53:17 +08:00
* @property string $user_agent 浏览器UA信息
*
* @property CollectionTasks $task
2024-04-06 13:53:17 +08:00
* @property User $user
*/
2024-02-26 15:42:18 +08:00
class CollectionUploaded extends ActiveRecord
{
/**
* {@inheritdoc}
*/
2024-03-05 15:08:11 +08:00
public static function tableName(): string
{
return 'collection_uploaded';
}
/**
* {@inheritdoc}
*/
public function rules(): array
{
return [
2024-04-06 13:53:17 +08:00
[['task_id', 'uploader_ip', 'subfolder_name', 'user_agent'], 'required'],
[['user_id', 'task_id'], 'integer'],
[['uploaded_at'], 'safe'],
[['uploader_ip'], 'string', 'max' => 45],
[['subfolder_name'], 'string', 'max' => 255],
[['task_id'], 'exist', 'skipOnError' => true, 'targetClass' => CollectionTasks::class, 'targetAttribute' => ['task_id' => 'id']],
2024-04-06 13:53:17 +08:00
[['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::class, 'targetAttribute' => ['user_id' => 'id']],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels(): array
{
return [
'id' => '上传记录id',
2024-04-06 13:53:17 +08:00
'user_id' => '用户ID',
'task_id' => '收集任务id',
'uploader_ip' => '上传者ip',
'uploaded_at' => '上传时间',
'subfolder_name' => '所在位置',
2024-04-06 13:53:17 +08:00
'user_agent' => '浏览器UA信息',
];
}
/**
* Gets query for [[Task]].
*
* @return ActiveQuery
*/
public function getTask(): ActiveQuery
{
return $this->hasOne(CollectionTasks::class, ['id' => 'task_id']);
}
2024-04-06 13:53:17 +08:00
/**
* Gets query for [[User]].
*
2024-04-22 14:37:03 +08:00
* @return ActiveQuery
2024-04-06 13:53:17 +08:00
*/
public function getUser()
{
return $this->hasOne(User::class, ['id' => 'user_id']);
}
}