1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace app\common\model;
- class Record extends Base
- {
- /**
- * 计算时长
- * @return int
- */
- public function computeRecordLong(){
- $begin=strtotime(date("Y-m-d ").$this->record_begin);
- $end=strtotime(date("Y-m-d ").$this->record_end);
- return intval(($end-$begin)/60);
- }
- /**
- * 关联类型
- * @return \think\model\relation\HasOne
- */
- public function type(){
- return $this->hasOne(Type::class,"id","type_id");
- }
- /**
- * 关联用户
- */
- public function user(){
- return $this->hasOne(User::class,"id","user_id");
- }
- }
|