file and some fix
This commit is contained in:
79
common/models/FileEntity.php
Normal file
79
common/models/FileEntity.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
|
||||
/**
|
||||
* This is the model class for table "file_entity".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $file_id
|
||||
* @property int $entity_type
|
||||
* @property int $entity_id
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
* @property int $status
|
||||
*
|
||||
* @property File $file
|
||||
*/
|
||||
class FileEntity extends \yii\db\ActiveRecord
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
'createdAtAttribute' => 'created_at',
|
||||
'updatedAtAttribute' => 'updated_at',
|
||||
'value' => new Expression('NOW()'),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'file_entity';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['file_id', 'entity_type', 'entity_id', 'status'], 'integer'],
|
||||
[['created_at', 'updated_at'], 'safe'],
|
||||
[['file_id'], 'exist', 'skipOnError' => true, 'targetClass' => File::className(), 'targetAttribute' => ['file_id' => 'id']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'file_id' => 'File ID',
|
||||
'entity_type' => 'Entity Type',
|
||||
'entity_id' => 'Entity ID',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'status' => 'Status',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getFile()
|
||||
{
|
||||
return $this->hasOne(File::className(), ['id' => 'file_id']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user