12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace common\models;
- use common\behaviors\CommentBehavior;
- use common\modules\user\models\User;
- use Yii;
- use yii\behaviors\BlameableBehavior;
- use yii\behaviors\TimestampBehavior;
- /**
- * This is the model class for table "{{%suggest}}".
- *
- * @property integer $id
- * @property string $title
- * @property string $content
- * @property integer $created_at
- * @property integer $user_id
- */
- class Suggest extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return '{{%suggest}}';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['title', 'content'], 'required'],
- [['user_id'], 'integer'],
- [['title'], 'string', 'max' => 128],
- [['content'], 'string', 'max' => 1000],
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'title' => '标题',
- 'content' => '内容',
- 'created_at' => '发布于',
- 'user_id' => '用户',
- ];
- }
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::className(),
- 'updatedAtAttribute' => false,
- ],
- [
- 'class' => BlameableBehavior::className(),
- 'createdByAttribute' => 'user_id',
- 'updatedByAttribute' => false,
- ],
- // [
- // 'class' => CommentBehavior::className()
- // ],
- ];
- }
- public function getUser()
- {
- return $this->hasOne(User::className(), ['id' => 'user_id']);
- }
- }
|