问题描述
where 子句条件后有 12 个作业行。所以我用foreach语句得到了12组属性ID。总共有大约 500 个属性分为 12 组(数量不同)。最后一个数组有 40 个属性 ID。我想将所有 500 个属性 ID 都放入 $attributesId 中,但此代码只能获取最后 40 个属性 ID(使用 dd 看到它)。我认为 collect() 方法不断将新集合替换为 $attributesId ,但我不知道如何累积插入它们。其他一切都有效。请帮忙。
$jobLines = JobLine::where('job_id',$job->id)
->whereHas('jobType',function ($q) {
$q->where('code','Job_Code');
})
->get();
foreach ($jobLines as $jobLine) {
$jobChildren = JobTypeChild::all();
$attributesId = collect($jobLine->attributes->toArray());
->pluck('job_type_attribute_id');
$this->jmAttributes = JobTypeAttribute::whereIn(
'job_type_attributes.id',$attributesId
)->join(
...table columns joining
)
->where('job_line_id',$jobLine->id)
->pluck(
'job_line_attributes.value','attribute_fields.name'
)
->toArray();
}
dd($attributesId);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)