Team.php
454 字节
<?php
namespace app\api\model;
use think\Model;
class Team extends Model
{
//表名
protected $name = 'team';
public function getTeamScoreAttr($value,$data){
$value=[];
$study = db('study')->where('team_id',$data['id'])->field('id')->select();
foreach ($study as $k => $v){
$value['score'] = db('study_score')->where('study_id',$study[$k]['id'])->sum('score');
}
return $value;
}
}