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.

87 lines
1.9 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_tem_file".
  7. *
  8. * @property int $id
  9. * @property int $user_id 父级id
  10. * @property string $name 名称
  11. * @property int $type 类型
  12. * @property string $alias 别名
  13. * @property string $path 地址
  14. * @property int $updated_at 更新时间
  15. * @property int $created_at 创建时间
  16. */
  17. class TemFile extends \yii\db\ActiveRecord
  18. {
  19. //类型type
  20. const TYPE_IMAGE = 1;//图片
  21. const TYPE_VIDEO = 2;//影视
  22. const TYPE_EXCEL = 3;//excel表单
  23. const TYPE_WORD = 4;//word文本
  24. const TYPE_TXT = 5;//txt文本
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public static function tableName()
  29. {
  30. return 'ats_tem_file';
  31. }
  32. /**
  33. * {@inheritdoc}
  34. */
  35. public function rules()
  36. {
  37. return [
  38. [['user_id', 'type'], 'integer'],
  39. [['name', 'path'], 'string', 'max' => 255],
  40. [['alias'], 'string', 'max' => 50],
  41. ];
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function attributeLabels()
  47. {
  48. return [
  49. 'id' => 'id',
  50. 'user_id' => '父级id',
  51. 'name' => '名称',
  52. 'type' => '类型',
  53. 'alias' => '别名',
  54. 'path' => '地址',
  55. 'updated_at' => '更新时间',
  56. 'created_at' => '创建时间',
  57. ];
  58. }
  59. /**
  60. * @author linyao
  61. * @email 602604991@qq.com
  62. * @created Nov 8, 2019
  63. *
  64. * 行为存储创建时间和更新时间
  65. */
  66. public function behaviors()
  67. {
  68. return [
  69. [
  70. 'class' => TimestampBehavior::className(),
  71. 'createdAtAttribute' => 'created_at',
  72. 'updatedAtAttribute' => 'updated_at',
  73. 'value' => function() {
  74. return time();
  75. },
  76. ],
  77. ];
  78. }
  79. }