我有一个表单供用户创建自定义问题.为此,用户需要介绍问题(例如:你的手机是什么?)以及字段类型(文本,长文本,复选框,选择菜单,单选按钮).如果用户选择复选框字段,选择菜单或单选按钮,则还需要引入问题的可用选项.
在数据库中,问题被插入问题和question_options表中,如:
问题表:
id question type conference_id
1 Text text 1
2 Checkbox checkbox 1
3 Radio radio_btn 1
4 select select_menu 1
5 textarea long_text 1
6 file file 1
Run Code Online (Sandbox Code Playgroud)
Registration_type_questions数据透视表:
id registration_type_id question_id required
1 1 1 1
2 1 2 1
3 1 3 0
4 1 4 0
5 1 5 0
6 1 6 1
Run Code Online (Sandbox Code Playgroud)
选项存储在questions_options表中:
id question_id value
1 2 check1
2 2 check2
3 3 rad1
4 3 rad2
5 4 select1
6 …Run Code Online (Sandbox Code Playgroud) 我有一个多步骤表单供用户在会议中注册,所有步骤都在同一registration.blade.php页面,在步骤1和步骤2完成ajax请求以验证表单字段.
步骤是:
我怀疑是在第2步和第3步之间.
如果执行下面的代码需要所选的付款方式参考,那么会生成一些付款参考,然后在步骤3中向用户提供该参考.当用户付款时,系统会收到通知并应插入付款表中price,payment_method_id,registration_id和status(付费).
使用参考资料处理付款的代码:
public function ReferencesCharge(Request $request)
{
$payment_info = [
'name' => "user name",
'email' => 'user email',
'value' => 'registration total price',
'id' => 'registration id',
];
$newPayment = new Payment($payment_info);
$reference = $newPayment->gererateReferences();
//$reference returns an array with necessary codes to present to the user so he can pay
// after generate references …Run Code Online (Sandbox Code Playgroud) 我在会议中有一个用户注册表.但是当用户点击"商店注册"时,它会显示未定义的偏移错误,问题应该是因为我没有正确组织此上下文.在会议中注册的表单是不同的,具体取决于会议桌的"all_participants"列是"1"还是"0".
如果会议表中的all_participants为1
如果会议桌具有值为"1"的列"all_participants",则表示需要收集每个参与者的姓名和姓氏(关于每个选定的注册类型).因此,表单将显示表单字段以收集每个参与者的姓名和姓氏.此外,如果"all_participants"为1,则如果某些选定的注册类型具有关联的自定义问题,则需要为每个参与者收集该问题的答案.在上图中,注册类型"常规"具有关联的自定义问题"电话",所以有必要收集两个参与者的答案,正在注册注册类型"一般".
在会议桌中将all_participants的形式显示为"1"的图像
用户点击"商店注册"后,应将其存储在如下表格中:
如果在conference表中all_participants为0
如果"all_participants"为"0",则表单只有一个字段"Phone",因为名称和姓氏直接来自经过身份验证的用户信息.并且因为"all_participants"为"0",仅需要收集正在进行注册的用户的电话(经过认证的用户),因为"all_participants"为"0",因此不需要其他参与者.因此,如果"all_participants"为"0",则表单在这种情况下只有一个字段(Phone).并且参与者表仅需要存储进行注册的用户的姓名和姓氏,因为其他参与者可以存储为空"".
如果all_participants为"0",则表格:
用户点击"商店注册"后,应将其存储在如下表格中:
对于"all_participants"的情况,此图像上下文的HTML为1:
<form method="post" id="registration_form" action="http://proj.test/conference/1/conference-title/registration/storeRegistration">
<h6>Participant - 1 - general</h6>
<div class="form-group">
<label for="namegeneral_1">Name</label>
<input type="text" id="namegeneral_1" name="participant_name[]" required="" class="form-control" value="">
</div>
<div class="form-group">
<label for="surnamegeneral_1">Surname</label>
<input type="text" id="surnamegeneral_1" required="" class="form-control" name="participant_surname[]" value="">
</div>
<div class="form-group">
<label for="participant_question">Phone?</label>
<input type="text" name="participant_question[]" class="form-control" required="">
<input type="hidden" name="participant_question_required[]" value="1">
<input type="hidden" value="1" name="participant_question_id[]">
</div>
<input type="hidden" name="rtypes[]" value="1">
<h6> Participant - 2 - general</h6>
<div class="form-group">
<label for="namegeneral_2">Name</label>
<input type="text" id="namegeneral_2" name="participant_name[]" required="" …Run Code Online (Sandbox Code Playgroud) 我在registration.blade.php页面上有一个表单,供用户输入一些信息在会议中进行注册.
在下面的表单中,有一个部分用于getHtmlInput()方法,该方法用于显示用户选择的每个故障单/注册类型与用户要回答的该注册类型相关联的自定义问题.如果在registration_type_questions数据透视表中,问题的"required"列为"1" ,则添加"required"属性.
如果用户在会议中进行注册并且用户没有选择具有相关自定义问题的票证/注册类型,则注册工作正常,则代码输入"if($ validator-> passes()) {...}".
问题:
问题是当存在与一个或多个所选票证/注册类型相关联的自定义问题时.
如果有需要的自定义问题,我想在Laravel中验证.所以我在下面的代码中storeRegistration()显示了"填写所有必填字段"消息,如果没有回答所需的自定义问题.
但即使用户填写了所有必需的自定义问题,代码也永远不会输入if" if ($validator->passes()) {...}".你知道为什么吗?此外,如果问题是必需的,并且从控制台中的HTML中删除了必需属性,并且用户单击"存储注册",则不会显示验证错误.
代码总是转到if"" if ($validator->passes()) {...}" 的else部分,并显示为" else{dd($validator->errors());}":
MessageBag {#278 ?
#messages: array:1 [?
"participant_question.0" => array:1 [?
0 => "The participant question.0 field is required."
]
]
#format: ":message"
}
Run Code Online (Sandbox Code Playgroud)
你知道问题出在哪里吗?
该storeRegistrationInfo()存储登记并有验证,以检查是否需要自定义的问题(S)均未得到答复:
public function storeRegistration(Request $request, $id, $slug = null, Validator $validator)
{
$user = Auth::user();
$rules = [];
$messages = [];
if (isset($request->participant_question_required)) {
dd($request->participant_question_required);
$messages = …Run Code Online (Sandbox Code Playgroud) 我有这个表格供用户介绍一些数据以在大会上注册。
首先他需要介绍一些买家信息,然后如果有一些付费票类型还有一些账单信息。然后,如果大会表将“collect_data_from_all_participants”列设为 1,则用户还需要为每个选定的票证类型引入信息。每种门票类型的信息是每个参与者的姓名和姓氏,因此我将“姓名”字段的名称设为“姓名”,将“姓氏”字段的名称设为“姓氏”。吨
然后他的问题出现在控制台中:
[DOM] Found 4 elements with non-unique id #name:
`DOM] Found 3 elements with non-unique id #surname:
Run Code Online (Sandbox Code Playgroud)
您知道纠正问题的最佳方法是什么吗?
<div class="registration_form mt-4">
<form method="post" class="clearfix">
<div class="tab-content registration_body bg-white" id="myTabContent">
<div class="tab-pane fade show active clearfix" id="step1" role="tabpanel" aria-labelledby="home-tab">
<h6>Buye information</h6>
<div class="form-group font-size-sm">
<label for="name" class="text-gray">Name</label>
<input type="text" required class="form-control" id="name" value="{{ (\Auth::check()) ? Auth::user()->name : old('name')}}">
</div>
<div class="form-group font-size-sm">
<label for="surname" class="text-gray">Surname</label>
<input type="text" required class="form-control" name="surname" id="surname" value="{{ (\Auth::check()) ? Auth::user()->surname : old('surname')}}">
</div> …Run Code Online (Sandbox Code Playgroud) 我正在使用 laravel 默认分页:
{{$posts->links()}}并且分页工作,链接出现并且工作正常。
但是风格是这样的:
你知道为什么不使用 bootstrap 4 默认样式吗?我正在使用 Bootstrap 4。
我也有内部视图/供应商/分页文件:
- bootstrap4-blade.php
-default.blade.php
-semantic-ui.blade.php
-simple-bootstra-4.blade.php
-simple-default.blade.php
Run Code Online (Sandbox Code Playgroud)
生成的 HTML:
<ul class="pagination">
<li class="disabled"><span>«</span></li>
<li class="active"><span>1</span></li>
<li><a href="http://proj.test/user/profile?page=2">2</a></li>
<li><a href="http://proj.test/user/profile?page=2" rel="next">»</a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
在“ http://proj.test/css/app.css ”中它出现:
.pagination {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
padding-left: 0;
list-style: none;
border-radius: 0.25rem;
}
.page-item:first-child .page-link {
margin-left: 0;
border-top-left-radius: 0.25rem;
border-bottom-left-radius: 0.25rem;
}
.page-item:last-child .page-link {
border-top-right-radius: 0.25rem;
border-bottom-right-radius: 0.25rem;
}
.page-item.active .page-link {
z-index: 2;
color: #fff;
background-color: #0FACF3;
border-color: #0FACF3; …Run Code Online (Sandbox Code Playgroud) 我想使用 jQuery 和 Laravel 进行自动完成搜索输入。但是当用户在搜索输入中输入至少 2 个字母时,我收到一个错误:
GET http://proj.test/autocomplete-search?term=ca 500 (Internal Server Error)
Run Code Online (Sandbox Code Playgroud)
你知道问题出在哪里吗?我想根据用户在搜索表单中插入的字母显示会议。
搜索输入:
<div class="col col-md-6">
<h4 class="text-white text-center font-weight-bold">Search</h4>
<form class="main-search">
<input type="text" id="search" class="autocomplete dropdown-toggle" placeholder="Conference, Citiy, Category">
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
Laravel 路线:
Route::get('/autocomplete-search', 'AutocompleteController@search');
Run Code Online (Sandbox Code Playgroud)
Laravel 自动完成控制器:
class AutocompleteController extends Controller
{
public function search(Request $request){
$search = $request->term;
$conferences = Conference::where('name', 'LIKE', '%'.$search.'%')->get();
$data= [];
foreach ($conferences as $key => $value){
$data[] = ['id'=>$value->id, 'value' => $value->id + " " + $value->name];
}
//dd($data);
return response($data); …Run Code Online (Sandbox Code Playgroud)