StudyScore.php
682 字节
<?php
namespace app\api\model;
use think\Db;
use think\Model;
class StudyScore extends Model
{
//绑定表名
protected $name = 'study_score_log';
// 追加属性
protected $append = [
'study_info',
];
//获取时间
public function getCreateTimeAttr($value){
return date('m.d H:i',$value);
}
public function getStudyInfoAttr($value,$data){
$value=[];
$s = db('study')->where('id',$data['study_id'])->find();
$value['name'] = $s['name'];
return $value;
}
public function study()
{
return $this->belongsTo('Study', 'study_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}