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.

92 lines
2.2 KiB

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