我想要从where government_type = 'higher_government‘中的每个记录中获取每个'stat’值,但目前我的代码只获取它找到的第一个政府角色的统计数据实例,我如何才能将所有统计数据放在某种类型的数组中?
$higherGovernment = Cache::remember('government.higher_government', 1, function() {
return GovernmentRole::where('government_type', 'higher_government')->first()->stats;
});统计关系:
public function government_role()
{
return $this->belongsTo('App\Database\Website\Roleplay\GovernmentRole', 'government_id');
}政府关系:1
public function stats(){
return $this->hasMany('App\Database\Website\User\Roleplay', 'government_id');
}https://stackoverflow.com/questions/41474141
复制相似问题