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.

95 lines
2.3 KiB

5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace backend\modules\file\models\ars;
  3. use yii\behaviors\TimestampBehavior;
  4. use yii\db\ActiveRecord;
  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 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. const OWN_TYPE_COMMENT = 4;//评论图片
  27. //is_delete
  28. const IS_DELETE_YES = 1;//已删除
  29. const IS_DELETE_NO = 0;//未删除
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public static function tableName()
  34. {
  35. return 'ats_file';
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function rules()
  41. {
  42. return [
  43. [['pid', 'type', 'own_type', 'own_id', 'is_delete'], 'integer'],
  44. [['name', 'path'], 'string', 'max' => 255],
  45. [['alias'], 'string', 'max' => 50],
  46. ];
  47. }
  48. /**
  49. * {@inheritdoc}
  50. */
  51. public function attributeLabels()
  52. {
  53. return [
  54. 'id' => 'id',
  55. 'pid' => '父级id',
  56. 'name' => '名称',
  57. 'type' => '类型',
  58. 'own_type' => '拥有者类型',
  59. 'own_id' => '拥有者id',
  60. 'alias' => '别名',
  61. 'path' => '地址',
  62. 'is_delete' => '是否删除,1为已删除',
  63. 'updated_at' => '更新时间',
  64. 'created_at' => '创建时间',
  65. ];
  66. }
  67. /**
  68. * @author linyao
  69. * @email 602604991@qq.com
  70. * @created Nov 8, 2019
  71. *
  72. * 行为存储创建时间和更新时间
  73. */
  74. public function behaviors()
  75. {
  76. return [
  77. [
  78. 'class' => TimestampBehavior::class,
  79. 'createdAtAttribute' => 'created_at',
  80. 'updatedAtAttribute' => 'updated_at',
  81. 'value' => function () {
  82. return time();
  83. },
  84. ],
  85. ];
  86. }
  87. }