【发布时间】:2018-04-10 16:27:39
【问题描述】:
我有一个 single.blade.php 文件,其中显示了大会详细信息,还有一个表格,以便用户可以为每种票证类型选择他想要的票证数量。
当用户选择数量并单击下一步时,请求转到具有 storeQuantity() 方法的 RegistrationController 来存储所选数量 由用户在 $selectedTypes 数组中,并使用 $selectedTypes 数组将用户重定向到registration.blade.php:
class RegistrationController extends Controller
{
public function storeQuantityandRedirect(Request $request, $id){
$typeQuantities = $request->get('types');
foreach($typeQuantities as $typeName => $quantity){
$type = TicketType::where('name', $typeName)->firstOrFail();
$price = $type->price;
$selectedTypes[$type->name]['quantity'] = $quantity;
$selectedTypes[$type->name]['price'] = $price;
}
return view('congresses.registration')->with('selectedTypes', $selectedTypes);
}
}
现在在registration.blade.php文件中,用户需要填写注册表。
如果用户选择了,例如注册页面上一页的2张票,应该出现两个部分供用户介绍 每个票类型的姓名和电子邮件。这适用于以下代码:
@foreach($selectedRtypes as $k=>$selectedRtype)
<h6>Participant - 1 - Ticket Type - {{$k}}</h6> <!-- The variable {{$k}} shows the name of each ticket type (ex: full access, basic, etc). -->
<div class="form-group font-size-sm">
<label for="name" class="text-gray">Name</label>
<input type="text" class="form-control" id="name" value="">
</div>
<div class="form-group font-size-sm">
<label for="surname" class="text-gray">Surname</label>
<input type="text" class="form-control" name="surname" id="surname" value="">
</div>
@endforeach
怀疑:
每种工单类型都可以有自定义问题。
我的疑问是如何显示除了姓名和姓氏字段外,还显示每种特定票证类型的自定义字段。 例如,会议组织者可能已经为工单类型“完全访问”创建了自定义问题“您的电子邮件是什么?”。所以在 foreach 当票证类型为“完全访问”时,除了姓名和姓氏外,还应显示“您的电子邮件是什么?”字段。
你知道怎么做吗?
我有这个表格内容和关系:
questions table:
id question congress_id
1 whats your email 1
ticket_type_questions table:
id ticket_type_id question_id
1 1 1 (the ticket type 1 has the question 1)
ticket types table
id name congress_id
1 full access 1
2 basic 1
【问题讨论】: