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.

90 lines
2.1 KiB

  1. <?php
  2. namespace backend\modules\shop\models\ars;
  3. use backend\modules\goods\models\ars\Goods;
  4. use Yii;
  5. use yii\behaviors\TimestampBehavior;
  6. /**
  7. * This is the model class for table "ats_delivery_goods".
  8. *
  9. * @property int $id
  10. * @property int $delivery_id 物流id
  11. * @property int $order_goods_id 订单商品id
  12. * @property int $goods_id 商品id
  13. * @property int $goods_name 商品名称
  14. * @property int $goods_count 商品数量
  15. * @property int $created_at 创建时间
  16. * @property int $updated_at 更新时间
  17. */
  18. class DeliveryGoods extends \yii\db\ActiveRecord
  19. {
  20. /**
  21. * {@inheritdoc}
  22. */
  23. public static function tableName()
  24. {
  25. return 'ats_delivery_goods';
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function rules()
  31. {
  32. return [
  33. [['delivery_id', 'order_goods_id', 'goods_id', 'goods_count'], 'integer'],
  34. [['goods_name'], 'string'],
  35. ];
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function attributeLabels()
  41. {
  42. return [
  43. 'id' => 'id',
  44. 'delivery_id' => '物流id',
  45. 'order_goods_id' => '订单商品id',
  46. 'goods_id' => '商品id',
  47. 'goods_name' => '商品名称',
  48. 'goods_count' => '商品数量',
  49. 'created_at' => '创建时间',
  50. 'updated_at' => '更新时间',
  51. ];
  52. }
  53. /**
  54. * @author linyao
  55. * @email 602604991@qq.com
  56. * @created Nov 8, 2019
  57. *
  58. * 行为存储创建时间和更新时间
  59. */
  60. public function behaviors()
  61. {
  62. return [
  63. [
  64. 'class' => TimestampBehavior::className(),
  65. 'createdAtAttribute' => 'created_at',
  66. 'updatedAtAttribute' => 'updated_at',
  67. 'value' => function() {
  68. return time();
  69. },
  70. ],
  71. ];
  72. }
  73. public function getGoods()
  74. {
  75. return $this->hasOne(Goods::className(), ['id' => 'goods_id']);
  76. }
  77. public function getOrderGoods()
  78. {
  79. return $this->hasOne(OrderGoods::className(), ['id' => 'order_goods_id']);
  80. }
  81. }