You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

93 lines
2.2 KiB

<?php
namespace backend\modules\shop\models\ars;
use Yii;
use yii\behaviors\TimestampBehavior;
use backend\modules\shop\models\ars\OrderGoods;
/**
* This is the model class for table "ats_comment".
*
* @property int $id
* @property int $user_id 用户id
* @property int $order_goods_id 订单详情商品id
* @property int $star 星级
* @property string $content 评论内容
* @property int $status 状态:1为显示,0为不显示
* @property int $updated_at 更新时间
* @property int $created_at 创建时间
*/
class Comment extends \yii\db\ActiveRecord
{
//状态
const STATUS_VIEW = 1; //显示
const STATUS_HIDE = 0; //隐藏
public static $commentStatus = [
self::STATUS_VIEW => '显示',
self::STATUS_HIDE => '隐藏'
];
/**
* {@inheritdoc}
*/
public static function tableName()
{
return 'ats_comment';
}
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['user_id'], 'required'],
[['user_id', 'order_goods_id', 'star', 'status'], 'integer'],
[['content'], 'string'],
];
}
/**
* {@inheritdoc}
*/
public function attributeLabels()
{
return [
'id' => 'id',
'user_id' => '用户id',
'order_goods_id' => '订单详情商品id',
'star' => '星级',
'content' => '评论内容',
'status' => '状态:1为显示,0为不显示',
'updated_at' => '更新时间',
'created_at' => '创建时间',
];
}
/**
* @author linyao
* @email 602604991@qq.com
* @created Nov 8, 2019
*
* 行为存储创建时间和更新时间
*/
public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function() {
return time();
},
],
];
}
public function getOrderGoods()
{
return $this->hasOne(OrderGoods::class,['id' => 'order_goods_id']);
}
}