Record.php 634 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\common\model;
  3. class Record extends Base
  4. {
  5. /**
  6. * 计算时长
  7. * @return int
  8. */
  9. public function computeRecordLong(){
  10. $begin=strtotime(date("Y-m-d ").$this->record_begin);
  11. $end=strtotime(date("Y-m-d ").$this->record_end);
  12. return intval(($end-$begin)/60);
  13. }
  14. /**
  15. * 关联类型
  16. * @return \think\model\relation\HasOne
  17. */
  18. public function type(){
  19. return $this->hasOne(Type::class,"id","type_id");
  20. }
  21. /**
  22. * 关联用户
  23. */
  24. public function user(){
  25. return $this->hasOne(User::class,"id","user_id");
  26. }
  27. }