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.

81 lines
1.9 KiB

  1. <?php
  2. namespace backend\modules\goods\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "atg_goods_attr".
  7. *
  8. * @property int $id
  9. * @property int $goods_id 商品id
  10. * @property int $attr_id 属性id
  11. * @property string $attr_value 属性名
  12. * @property int $is_delete 是否删除,1为已删除
  13. * @property int $created_at 创建时间
  14. * @property int $updated_at 更新时间
  15. */
  16. class GoodsAttr extends \yii\db\ActiveRecord
  17. {
  18. //是否删除is_delete
  19. const IS_DELETE_NO = 0;//未删除
  20. const IS_DELETE_YES = 1;//已删除
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public static function tableName()
  25. {
  26. return 'atg_goods_attr';
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function rules()
  32. {
  33. return [
  34. [['attr_value'], 'required'],
  35. [['goods_id', 'attr_id', 'is_delete'], 'integer'],
  36. [['attr_value'], 'string', 'max' => 50],
  37. ];
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function attributeLabels()
  43. {
  44. return [
  45. 'id' => 'id',
  46. 'goods_id' => '商品id',
  47. 'attr_id' => '属性id',
  48. 'attr_value' => '属性名',
  49. 'is_delete' => '是否删除,1为已删除',
  50. 'created_at' => '创建时间',
  51. 'updated_at' => '更新时间',
  52. ];
  53. }
  54. /**
  55. * @author linyao
  56. * @email 602604991@qq.com
  57. * @created Nov 8, 2019
  58. *
  59. * 行为存储创建时间和更新时间
  60. */
  61. public function behaviors()
  62. {
  63. return [
  64. [
  65. 'class' => TimestampBehavior::className(),
  66. 'createdAtAttribute' => 'created_at',
  67. 'updatedAtAttribute' => 'updated_at',
  68. 'value' => function() {
  69. return time();
  70. },
  71. ],
  72. ];
  73. }
  74. }