ResidentLog.php 832 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class ResidentLog extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'userid' => 'int',
  10. 'residentid' => 'int',
  11. 'workerid' => 'int',
  12. 'content' => 'string',
  13. 'createtime' => 'int',
  14. ];
  15. // 设置字段自动转换类型
  16. protected $type = [
  17. 'createtime' => 'timestamp:Y-m-d H:i:s',
  18. ];
  19. // 关联User
  20. public function user()
  21. {
  22. return $this->hasOne(User::class, "id", "userid");
  23. }
  24. // 关联resident
  25. public function resident()
  26. {
  27. return $this->hasOne(Resident::class, "id", "residentid");
  28. }
  29. // 关联worker
  30. public function worker()
  31. {
  32. return $this->hasOne(Worker::class, "id", "workerid");
  33. }
  34. }