AdoptGoods.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\plugins\adopt\models;
  8. use yii\db\ActiveRecord;
  9. use yii\behaviors\TimestampBehavior;
  10. /**
  11. * Class Goods
  12. * @package app\modules\common\models
  13. * @property integer $id
  14. * @property integer $store_id
  15. * @property integer $goods_id
  16. * @property integer $growth_cycle
  17. * @property string $desc
  18. * @property string $yield
  19. * @property string $varieties
  20. * @property string $adopt_income
  21. * @property string $self_pick_date
  22. * @property string $self_pick_times
  23. * @property integer $is_delete
  24. * @property string $created_at
  25. * @property string $updated_at
  26. */
  27. class AdoptGoods extends ActiveRecord
  28. {
  29. public static function tableName()
  30. {
  31. return '{{%adopt_goods}}';
  32. }
  33. public function behaviors()
  34. {
  35. return [
  36. [
  37. // 自动更新创建和更新时间
  38. 'class' => TimestampBehavior::class,
  39. 'value' => time()
  40. ]
  41. ];
  42. }
  43. public function rules()
  44. {
  45. return [
  46. [['store_id', 'goods_id',], 'required', 'on' => self::whenSave()],
  47. [['store_id', 'goods_id', 'is_delete', 'created_at', 'updated_at', 'growth_cycle' ], 'integer', 'on' => self::whenSave()],
  48. [['desc', 'yield', 'varieties', ], 'string', 'max' => 255, 'on' => self::whenSave()],
  49. [['adopt_income', 'self_pick_date', 'self_pick_times'], 'string', 'on' => self::whenSave()],
  50. [['goods_id', 'store_id'], 'integer', 'on' => self::whenList()],
  51. ];
  52. }
  53. public function attributeLabels()
  54. {
  55. return [
  56. 'id' => 'ID',
  57. 'store_id' => 'Store ID',
  58. 'goods_id' => '商品id',
  59. 'desc' => '认养简介',
  60. 'yield' => '认养产量',
  61. 'varieties' => '认养品种',
  62. 'growth_cycle' => '生长周期',
  63. 'adopt_income' => '认养收获',
  64. 'self_pick_date' => '自采日期',
  65. 'self_pick_times' => '自采时间',
  66. 'is_delete' => 'Is Delete',
  67. 'created_at' => '创建时间',
  68. 'updated_at' => '更新时间',
  69. ];
  70. }
  71. public static function whenSave ()
  72. {
  73. return 'save';
  74. }
  75. public static function whenList ()
  76. {
  77. return 'list';
  78. }
  79. }