12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class CheckCard extends Model
- {
- protected $table = 'check_cards';
- protected $guarded = [];
- public function student()
- {
- return $this->belongsTo('App\Models\Student');
- }
- public function studentCourse()
- {
- return $this->belongsTo('App\Models\StudentCourse');
- }
- public function course()
- {
- return $this->belongsTo('App\Models\Course');
- }
- public function getDuration()
- {
- $res = '';
- if(!empty($this['begin_date_time']) && !empty($this['end_date_time'])) {
- $begin_time = strtotime($this['begin_date_time']);
- $end_time = strtotime($this['end_date_time']);
- if($end_time > $begin_time) {
- $diff_time = $end_time - $begin_time;
- $tmp = floor($diff_time / 3600);
- $diff_time = $diff_time % 3600;
- if(!empty($tmp)) {
- $res .= $tmp . '小时';
- }
- $tmp = floor($diff_time / 60);
- $diff_time = $diff_time % 60;
- if(!empty($tmp)) {
- $res .= $tmp . '分钟';
- }
- if(!empty($diff_time)) {
- $res .= $diff_time . '秒';
- }
- return $res;
- }
- }
- return $res;
- }
- }
|