49 lines
851 B
PHP
49 lines
851 B
PHP
<?php
|
|
|
|
namespace app\models;
|
|
|
|
class Comment extends \yii\db\ActiveRecord
|
|
{
|
|
public $id;
|
|
public $user_id;
|
|
public $material_id;
|
|
|
|
public $content;
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['id', 'user_id', 'material_id', 'content'], 'required'],
|
|
[['id', 'user_id', 'material_id'], 'integer'],
|
|
[['content'], 'string'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function getUser()
|
|
{
|
|
return $this->hasOne(User::class, [ 'id' => 'user_id' ]);
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function getMaterial()
|
|
{
|
|
return $this->hasOne(Material::class, [ 'id' => 'material_id' ]);
|
|
}
|
|
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function tableName()
|
|
{
|
|
return "comments";
|
|
}
|
|
}
|