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.3 KiB

  1. <?php
  2. namespace backend\models\ars;
  3. use Yii;
  4. use yii\behaviors\TimestampBehavior;
  5. /**
  6. * This is the model class for table "ats_file".
  7. *
  8. * @property int $id
  9. * @property int $pid 父级id
  10. * @property string $name 名称
  11. * @property int $type 类型
  12. * @property int $own_type 拥有者类型
  13. * @property int $own_id 拥有者id
  14. * @property string $alias 别名
  15. * @property string $path 地址
  16. * @property int $is_delete 是否删除,1为已删除
  17. * @property int $updated_at 更新时间
  18. * @property int $created_at 创建时间
  19. */
  20. class File extends \yii\db\ActiveRecord
  21. {
  22. //own_type
  23. const OWN_TYPE_GOODS_INDEX = 1;//商品首页
  24. const OWN_TYPE_GOODS_DETAILS = 2;//商品详情
  25. const OWN_TYPE_CATEGORY_ICON = 3;//类目图标
  26. //is_delete
  27. const IS_DELETE_YES = 1;//已删除
  28. const IS_DELETE_NO = 0;//未删除
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public static function tableName()
  33. {
  34. return 'ats_file';
  35. }
  36. /**
  37. * {@inheritdoc}
  38. */
  39. public function rules()
  40. {
  41. return [
  42. [['pid', 'type', 'own_type', 'own_id', 'is_delete'], 'integer'],
  43. [['name', 'path'], 'string', 'max' => 255],
  44. [['alias'], 'string', 'max' => 50],
  45. ];
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public function attributeLabels()
  51. {
  52. return [
  53. 'id' => 'id',
  54. 'pid' => '父级id',
  55. 'name' => '名称',
  56. 'type' => '类型',
  57. 'own_type' => '拥有者类型',
  58. 'own_id' => '拥有者id',
  59. 'alias' => '别名',
  60. 'path' => '地址',
  61. 'is_delete' => '是否删除,1为已删除',
  62. 'updated_at' => '更新时间',
  63. 'created_at' => '创建时间',
  64. ];
  65. }
  66. /**
  67. * @author linyao
  68. * @email 602604991@qq.com
  69. * @created Nov 8, 2019
  70. *
  71. * 行为存储创建时间和更新时间
  72. */
  73. public function behaviors()
  74. {
  75. return [
  76. [
  77. 'class' => TimestampBehavior::className(),
  78. 'createdAtAttribute' => 'created_at',
  79. 'updatedAtAttribute' => 'updated_at',
  80. 'value' => function() {
  81. return time();
  82. },
  83. ],
  84. ];
  85. }
  86. }