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.

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