我有4种订阅类型(每月,3个月,6个月和每年)。我成功插入了与我的产品型号有关的值。现在,我需要进行更新。方案是用户在开始时仅选择两个订阅计划,然后决定添加更多订阅。在我的编辑中,它仅显示用户选择的内容。
@foreach($product->subscriptions as $subscription)
<input class="form-check-input" name="availability[]" type="checkbox" value="{{ $row->id }}" checked>
<label class="form-check-label" for="materialUnchecked"><b>{{ $subscription->name }}</b></label>
<input type="text" name="price[]" value="{{ $subscription->pivot->price }}">
@endforeach
如果结果小于4,我想不显示剩余的订阅可用性。例如,用户仅选择每月和每年。现在,在我的编辑视图中,我想同时显示其他两个(3个月和6个月的选项),以防他们想要添加一些内容。怎么做?
@foreach($subscriptions as $subscription)
<input class="form-check-input" name="availability[]" type="checkbox" value="{{ $row->id }}" {{in_array($subscription->id, $product->subscriptions->pluck('id')) ? 'checked' : ''}}>
<label class="form-check-label" for="materialUnchecked"><b>{{ $subscription->name }}</b></label>
<input type="text" name="price[]" value="{{ $subscription->pivot->price }}">
@endforeach