【发布时间】:2018-11-08 20:24:34
【问题描述】:
我有一个客户索引,其中显示了他们的购买摘要。
如果他们的任何购买未被同意,我需要在接受栏中打叉。为此,我将为每个客户创建一个接受数组,并使用 in_array() 来检查 null
但是我无法为每个客户创建一个数组,它只保留一个接受数组并从两个客户那里添加值。
客户控制器(索引)
$customers = Customer::with('paymentplans')->orderBy('created_at', 'desc')->get();
客户索引
foreach($customers as $customer){
foreach($customer->paymentplan as $plan){
$acceptance[] = $plan->accepted;
}
}
这将输出以下数组:
array:7 [▼
0 => null
1 => 1
2 => 1
3 => 1
4 => 1
5 => 1
6 => 1
]
我的两个客户需要这样的东西
array:5 [▼
0 => null
1 => 1
2 => 1
3 => 1
4 => 1
]
array:2 [▼
0 => 1
1 => 1
]
【问题讨论】: