This commit is contained in:
weiz 2023-10-25 17:45:41 +08:00
parent ea1f5ca2c1
commit c2306073a0
1 changed files with 18 additions and 2 deletions

View File

@ -119,13 +119,29 @@ class UserController extends BaseApiController
if($params['type'] == 3){
foreach($arr1 as $k=>$v) {
$actionIds = array_column($v['actions'],'id');
$arr1[$k]['action_record'] = Db::name('farmer_animal_record')->where('action_id','in',$actionIds)->order('id desc')->limit(5)->select();
$actionsInfo = $v['actions'];
$arr1[$k]['action_record'] = Db::name('farmer_animal_record')->where('action_id','in',$actionIds)->order('id desc')->limit(5)->select()->each(function($item)use($actionsInfo){
foreach ($actionsInfo as $val){
if($item['action_id'] == $val['id']){
$item['action_name'] = $val['name'];
}
}
return $item;
});
}
}
if($params['type'] == 2) {
foreach($arr1 as $k=>$v) {
$actionIds = array_column($v['actions'],'id');
$arr1[$k]['action_record'] = Db::name('farmer_poultry_record')->where('action_id','in',$actionIds)->order('id desc')->limit(5)->select();
$actionsInfo = $v['actions'];
$arr1[$k]['action_record'] = Db::name('farmer_poultry_record')->where('action_id','in',$actionIds)->order('id desc')->limit(5)->select()->each(function($item)use($actionsInfo){
foreach ($actionsInfo as $val){
if($item['action_id'] == $val['id']){
$item['action_name'] = $val['name'];
}
}
return $item;
});
}
}
return $this->success('请求成功',$arr1);