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.

82 lines
1.8 KiB

  1. <?php
  2. namespace backend\modules\shop\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "ats_express_template".
  7. *
  8. * @property int $id
  9. * @property string $name 名称
  10. * @property int $updated_at 更新时间
  11. * @property int $created_at 创建时间
  12. * @property int $calculation_type 计算方式
  13. */
  14. class ExpressTemplate extends \yii\db\ActiveRecord
  15. {
  16. //计算方式calculation_type
  17. const CALCULATION_TYPE_WEIGHT = 1; //按重量
  18. const CALCULATION_TYPE_NUMBER = 2; //按件数
  19. public static $calculationType = [
  20. self::CALCULATION_TYPE_WEIGHT => '按重量',
  21. self::CALCULATION_TYPE_NUMBER => '按件数'
  22. ];
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public static function tableName()
  27. {
  28. return 'ats_express_template';
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function rules()
  34. {
  35. return [
  36. [['name'], 'required'],
  37. [['calculation_type'], 'integer'],
  38. [['name'], 'string', 'max' => 255]
  39. ];
  40. }
  41. /**
  42. * {@inheritdoc}
  43. */
  44. public function attributeLabels()
  45. {
  46. return [
  47. 'id' => 'id',
  48. 'name' => '名称',
  49. 'updated_at' => '更新时间',
  50. 'created_at' => '创建时间',
  51. 'calculation_type' => '计算方式',
  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. }